شيوخ@محرق Posted أكتوبر 16, 2007 Report Share Posted أكتوبر 16, 2007 ذي حل اسايمنت 3 الي يبيه #include<iostream> #include<string> using namespace std; struct student { string name; long ID; float score; }; void Bubblesort( student arr[],int size ); float avg (student arr[],int size); void Bubblesort( student arr[],int size ) { for (int i=size-2; i>=0;i--) for (int j=0;j<=i;j++) if ( arr[j].score > arr[j+1].score ) { int temp; temp=arr[j].score; arr[j].score=arr[j+1].score; arr[j+1].score=temp; } } float avg (student arr[],int size) { double sum=0; for( int i=0;i<size;i++) sum+=arr.score; return (sum) /20; } void main() { student arr[20]; int size=3; for( int i=0;i<size;i++) { cin>>arr.name; cin>>arr.ID; cin>>arr.score; } Bubblesort(arr,size); cout<<avg (arr,size); } Link to comment Share on other sites More sharing options...
فيض من الدموع Posted أكتوبر 29, 2007 Report Share Posted أكتوبر 29, 2007 مشكورة حبيبتي شيوخ@محرق ما تقصرين عساج دوم ع القوة Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted أكتوبر 29, 2007 Report Share Posted أكتوبر 29, 2007 حاظرين اي وقت ابوي بس سوري اسايمنت 4 مانزلته لأن فيه ايرور واحد وعيزت معاه ماعرفت شنو هو Link to comment Share on other sites More sharing options...
فيض من الدموع Posted نوفمبر 1, 2007 Report Share Posted نوفمبر 1, 2007 عادي خيتو حطيه، بنشوف الايرور يمكن نعرف نعدله فيج الخير Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted نوفمبر 1, 2007 Report Share Posted نوفمبر 1, 2007 #include<iostream> using namespace std; class Circle { private: int xCenter; int yCenter; float radius; public: Circle (int xCenter=0, int yCenter=0, float radius=0 ); void setr ( float r ); float getr (); float CalculateArea ( float a ); void print (); }; Circle::Circle( int x, int y, float r) { xCenter=x; yCenter=y; radius=r; } void Circle:: setr (float r) { radius=r; } float Circle::getr () { return radius; } float Circle:: CalculateArea ( float a ) { a=radius*radius*3.14; } void print () { int a,xCenter,yCenter; cout<<xCenter<<" "<<yCenter<<" "<<"="<<a<<endl; } int main() { Circle m; m.setr (2.5); cout<<m.getr (); cout<<m.CalculateArea (1.5); m.print(); return 0; } خلاص انا سلمته اصلا وبنزل لكم الاسايمنت الثاني اول ماخلصه Link to comment Share on other sites More sharing options...
فيض من الدموع Posted نوفمبر 8, 2007 Report Share Posted نوفمبر 8, 2007 متشكرة الله يوفقج ياااااااااااااااارب Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted نوفمبر 13, 2007 Report Share Posted نوفمبر 13, 2007 قوه ... عندي اسايمنت ياريت الي يعرف يحله يساعدني لازم اسلمه باجر آخر يوم همتكم معااااااي وذي الاسايمنت :: Create a class called BloodDonor that maintains information about blood donors in a blood bank having the following data members: 1. IdNumber, // long int 2. name, //Name of donor, maximum 20 Characters 3. bloodGroup //String 4. home_Phone//String 5. mobile_Phone//String 6. address // struct Address that holds int house number, int road number, int block number, string city, and string country It will also have the following member functions: 1. Constructor function with default values IdNumber = 0, name = “”, bloodGroup = “”, home_Phone=””, mobile_Phone=””, address={0,0,0,””,””} which is passed as int,int,int,char[], and char[] 2. An overloaded constructor that takes the same parameters of the constructor in except Address for the address 3. Set and get functions for all data members. The setBloodgroup function should check the validity of the blood group before assigning it to bloodGroup by calling the function Is_BloodBroup_Valid deb2d***ibed below. 4. Overloaded functions for setAddress one that takes an Address as parameter and the other one takes int,int,int,char [], and char[] for address 5. Is_BloodBroup_Valid // takes a string as parameter and return true if it is a valid group and false if not. The only possible blood groups are A+, A-, B+, B-, O+, O-, AB+, AB-. 6. InputDetails// asks the user to enter all the details of a donor and then assign the values to the data members by calling the appropriate set functions. 7. printDetails // Print the details (IdNumber,name, bloodGroup, home phone, mobile phome, and address) of the donor 8. Destructor function . PART A Write the class BloodDonor including the code of the member functions. PART B Write a main function which includes the following: 1. Creates an instance (object) named donor1 of type BloodDonor with id=56789, name is Ahmed, blood group is B+, home phone=“17123456”, mobile phone=”39999999”, address={1,1,1,”Manama”,”Bahrain”}. 2. Write a statement to change the mobile phone to “39888888”. 3. Write a statement to print the mobile phone. 4. Write a statement to print the details of donor. 5. Creates another object named donor2 of type BloodDonor. 6. Ask the user to enter the details of the donor2 and store them in the object. 7. Print the details of donor2. Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted نوفمبر 13, 2007 Report Share Posted نوفمبر 13, 2007 انا حليت شوي وهذاني اكمل وهذي حلي والي يقدر يفيدني لا يتردد بليز محتاجتكم:: #include<iostream> #include<string> using namespace std; struct address{ int houseNo; int roadNo; int blockNo; string city; string country; }; class BloodDonor { private: long IdNumber; char name[20]; string bloodGroup; string home_Phone; string mobile_Phone; Address a; Public: BloodDonor(long id=0, string n=" ",string h=" ",string m=" ",struct a=("0","0","0"," "," ")); BloodDonor(long id, string n,string h,string m); void setIDNumber(long); void setname(char); void setbloodGroup(string); void sethome_Phone(string); void setmobile_Phone(string); void setaddress(int,int,int,string,string); long getIDNumber(long); char getname(char); string getbloodGroup(string); string gethome_Phone(string); string getmobile_Phone(string); void getaddress(int,int,int,string,string); bool Is_BloodBroup_Valid(string E) bool BloodDonor:: Is_BloodBroup_Valid(string E) { if( E=="A+") return true Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted نوفمبر 13, 2007 Report Share Posted نوفمبر 13, 2007 وهذي هو بس لحين ماخلصته بليز طلبتكم ساعدوووني #include<iostream> #include<string> using namespace std; struct address{ int houseNo; int roadNo; int blockNo; string city; string country; }; class BloodDonor { private: long IdNumber; string name[20]; string bloodGroup; string home_Phone; string mobile_Phone; address a; Public: BloodDonor(long id=0, string n=" ",string h=" ",string m=" ",struct a=("0","0","0"," "," ")); BloodDonor(long id, string n,string h,string m); void setIDNumber(long); void setname(string); void setbloodGroup(string); void sethome_Phone(string); void setmobile_Phone(string); void setaddress(int,int,int,city[],country[]); long getIDNumber(long); string getname(string); string getbloodGroup(string); string gethome_Phone(string); string getmobile_Phone(string); void getaddress(int,int,int,string,string); bool Is_BloodBroup_Valid(string E); void InputDetails(); void printDetails(); ~BloodDonor(); }; BloodDonor::BloodDonor(long id=0, string n=" ",string h=" ",string m=" ",struct a=("0","0","0"," "," ")) { setIDNumber(0); setname(" "); setbloodGroup(" "); sethome_Phone(" "); setmobile_Phone(" "); setaddress(0,0,0,city[],country[]); } BloodDonor::BloodDonor(long id, string n,string h,string m) { setIDNumber(id); setname(n); setbloodGroup(h); sethome_Phone(m); } void BloodDonor::setIDNumber(long) { IdNumber=id; } void BloodDonor::setname(string) { name[20]=n; } void BloodDonor::setbloodGroup(string) { bloodGroup=h; } void BloodDonor::sethome_Phone(string) { home_Phone=m; } void BloodDonor::setmobile_Phone(string) { mobile_Phone=s; } void BloodDonor::setaddress(int,int,int,city[],county[]) { a.address=(0,0,0,city[],country[]); } long BloodDonor::getIDNumber(long) { id=IdNumber; } string BloodDonor::getname(string) { n=name[20]; } string BloodDonor::getbloodGroup(string) { h=bloodGroup; } string BloodDonor::gethome_Phone(string) { m=home_Phone; } string BloodDonor::getmobile_Phone(string) { s=mobile_Phone; } void BloodDonor::getaddress(int,int,int,string,string) { (0,0,0,city[],country[])=a.address; } bool BloodDonor::Is_BloodBroup_Valid(string E) { if(E=="A+") return true; else if(E=="A-") return true; else if(E=="B+") return true; else if(E=="B-") return true; else if(E=="O+") return true; else if(E=="O-") return true; else if(E=="AB+") return true; else if(E=="AB-") return true; else return false; } void BloodDonor::InputDetails() { cout<<"enter your IdNumber, name, blood group, home phone, mobile phone, house number, block number, city and your country"; setIDNumber(long); setname(string); setbloodGroup(string); sethome_Phone(string); setmobile_Phone(string); setaddress(int,int,int,city[],country[]); } void BloodDonor::printDetails() { cout<<"Id number="<<IdNumber<<" "<<"name="<<name[20]<<"blood group="<<bloodGroup<< "home phone="<<home_Phone<<"mobile phone="<<mobile_Phone<<"address="<<address a; } int main(){ return 0; } Link to comment Share on other sites More sharing options...
شيوخ@محرق Posted نوفمبر 14, 2007 Report Share Posted نوفمبر 14, 2007 وهذي آخر حلي لليوم فيه 7 ايرور بليز الي يعرف يعدله لأن لاوم اسلمه قبل ال 12 :: #include<iostream> #include<string> using namespace std; struct address{ int houseNo; int roadNo; int blockNo; string city; string country; }; class BloodDonor { private: long IdNumber; string name[20]; string bloodGroup; string home_Phone; string mobile_Phone; address a; Public: BloodDonor(long id=0, string n=" ",string h=" ",string m=" ",struct a=("0","0","0"," "," ")); BloodDonor(long id, string n,string h,string m); void setIDNumber(long); void setname(string); void setbloodGroup(string); void sethome_Phone(string); void setmobile_Phone(string); void setaddress(int,int,int,city[],country[]); long getIDNumber(long); string getname(string); string getbloodGroup(string); string gethome_Phone(string); string getmobile_Phone(string); void getaddress(int,int,int,string,string); bool Is_BloodBroup_Valid(string E); void InputDetails(); void printDetails(); ~BloodDonor(); }; BloodDonor::BloodDonor(long id=0, string n=" ",string h=" ",string m=" ",struct a=("0","0","0"," "," ")) { setIDNumber(0); setname(" "); setbloodGroup(" "); sethome_Phone(" "); setmobile_Phone(" "); setaddress(0,0,0,city[],country[]); } BloodDonor::BloodDonor(long id, string n,string h,string m) { setIDNumber(id); setname(n); setbloodGroup(h); sethome_Phone(m); } void BloodDonor::setIDNumber(long) { IdNumber=id; } void BloodDonor::setname(string) { name[20]=n; } void BloodDonor::setbloodGroup(string) { bloodGroup=h; } void BloodDonor::sethome_Phone(string) { home_Phone=m; } void BloodDonor::setmobile_Phone(string) { mobile_Phone=s; } void BloodDonor::setaddress(int,int,int,city[],county[]) { a.address=(0,0,0,city[],country[]); } long BloodDonor::getIDNumber(long) { id=IdNumber; } string BloodDonor::getname(string) { n=name[20]; } string BloodDonor::getbloodGroup(string) { h=bloodGroup; } string BloodDonor::gethome_Phone(string) { m=home_Phone; } string BloodDonor::getmobile_Phone(string) { s=mobile_Phone; } void BloodDonor::getaddress(int,int,int,string,string) { (0,0,0,city[],country[])=a.address; } bool BloodDonor::Is_BloodBroup_Valid(string E) { if(E=="A+") return true; else if(E=="A-") return true; else if(E=="B+") return true; else if(E=="B-") return true; else if(E=="O+") return true; else if(E=="O-") return true; else if(E=="AB+") return true; else if(E=="AB-") return true; else return false; } void BloodDonor::InputDetails() { cout<<"enter your IdNumber, name, blood group, home phone, mobile phone, house number, block number, city and your country"<<endl; setIDNumber(long); setname(string); setbloodGroup(string); sethome_Phone(string); setmobile_Phone(string); setaddress(int,int,int,city[],country[]); } void BloodDonor::printDetails() { cout<<"Id number="<<IdNumber<<" "<<"name="<<name[20]<<"blood group="<<bloodGroup<< "home phone="<<home_Phone<<"mobile phone="<<mobile_Phone<<"address="<<address a; } void main() { bloodDonor donor1(56789,Ahmed,B+,17123456,39999999,1,1,1,manama,Bahrain); donor1.setmobile(39688888) cout<<donor1.getMobilephone(); donor1.printDetails(); bloodDonor donor2; long i,string n,string b,string hm,string m,int hn,int rn,int bn, string city,string country; cout<<"Enter your id:"; cin>>id; cout<<"Enter your name:"; cin>>name; cout<<"Enter your home phone:"; cin>>h; cout<<"Enter your mobile phone:"; cin>>m; cout<<"Enter your house number:"; cin>>house; cout<<"Enter your road number:"; cin>>road; cout<<"Enter your block number:"; cin>>block; cout<<"Enter your city name:"; cin>>city; cout<<"Enter your country name:"; cin>>country; donor2.set id(i); donor2.set name(n); donor2.set home(h); donor2.set mobile(m); donor2.set house(h); donor2.set road®; donor2.set block(b); donor2.set city(city); donor2.set country(country); donor2.getaddress(long i,string n,string b,string hm,string m,int hn,int rn,int bn, string city,string country) donor2.printDetails(); } Link to comment Share on other sites More sharing options...
Recommended Posts