Anda di halaman 1dari 4

//RISHABH JAIN

//XII-I
//QUESTION-l #include<iostream.h> #include<stdio.h> #include<string.h> class garment { char gcode[50]; char gtype[50]; int gsize; char gfabric[50]; float gprice; void assign(); public: garment() { gsize=O; gprice=O; strcpy(gcode,"NOT ALLOTED"); strcpy(gfabric,"NOT ALLOTED"); strcpy(gtype,"NOT ALLOTED"); } void input(); void display(); }; void garment::assignO { if(strcmp(gfabric,"cotton")==O) { if( strcmp(gtype, "trouser")==O) gprice= 1300; else gprice=1100; } else { if( strcmp(gtype, "trouser")==O) gprice=1300-(1300*.10); else gprice= 1100-(1100*.10); } } void garment: .input() {

,.

cout"enter the gcode"; gets(gcode ); cout"enter garment type";

gets(gtype ); cout"enter the garment size"; cin>>gsize; cout"enter the garment fabric"; gets(gfabric); assign(); } void garment: .display() { cout< <gcode< < endl < <gtype< < endl < <gsize< <endl < <gfabric< <endl < <gprice; } void main() { garment g 1 ; g l.inputi); g l.displayt); } *****************************Output ************************ enter the gcodedgfad enter garment typeshirt enter the garment size 12 enter the garment fabriccotton dgfad shirt 12 cotton 1100

//RISHABH JAIN //XII-I #include<iostream.h> #include<stdio.h> #include<string.h> class tour { char TCode[20]; int NoOfAdults; int NoOfKids; int Kilometres; float TotalFare; public: tourt) { strcpy(TCode, "NULL"); N oOfAdults= NoOfKids= Kilometres=TotalFare=O; } void Assign(); void entertour(); void showtour(); }; void tour: .entertour() { cout"enter the tour details:\n"; cout=<<'Tcode:"; cinTCode; cout"No Of Adults:"; cinNoOfAdults; cout"No OfKY cinNoOfKids, cout< <"Kilometres:"; cin>>Kilomertes; Assign(); } void tour: :AssignO { if(Kilometres>=1000)TotalF are=500; else if(Kilometres>=500)TotaIFare=300; else TotaIFare=200; TotaIFare*=NoOfAdults+NoOfKids/2.0; } void tour::showtourO { cout"Tour Details:\n"; cout" Tcode: "TCodeendl; cout"No Of Adults"NoOfAdultsendl; cout"No of Kids: "NoOfKidsendl; cout"Total Fare"<<TotaIFare<<endl;

} void main() { tour a; a.entertour(); a.showtouR();


}

*******************************Output ******************************* enter the tour details: Tcode:123 No Of Adults:2 No OfKids:2 Kilometres:4677 Tour Details: Tcode:123 No Of Adults2 No ofKids:2 Total Fare1500

Anda mungkin juga menyukai