You are on page 1of 12

EXP 10_1 INPUT #include<iostream.h> #include<conio.

h> class furniture { char material[20]; long int price; public: void acceptf() { cout<<"Enter material and price of the furniture"; cin>>material>>price; } void displayf() { cout<<"\nMaterial:"<<material<<"\nPrice:"<<price; } }; class table:public furniture { int sa,height; public: void acceptt() { cout<<"Enter the height"; cin>>height;

cout<<"Enter the surface area of the furniture"; cin>>sa; } void displayt() { cout<<"\nHeight"<<height<<"\nSurface Area"<<sa; } }; void main() { clrscr(); table t; t.acceptf(); t.acceptt(); t.displayf(); t.displayt(); getch(); } OUTPUT Enter material and price of the furniturePlywood 6000 Enter the height190 Enter the surface area of the furniture1900

Material:Plywood Price:6000 Height190

Surface Area1900

EXP10_2 INPUT #include<iostream.h> #include<conio.h> class student { long int roll_no; char name[20]; public: void accepts() { cout<<"Enter Roll no and name"; cin>>roll_no>>name; } void displays() { cout<<"Roll no and name:"<<roll_no<<"\t"<<name; } }; class test:public student { public: int m1,m2; void acceptt() { cout<<"Enter two marks"; cin>>m1>>m2;

} }; class result:public test { long int total; public: void displayr() { total=m1+m2; cout<<"\nTotal:\t"<<total; } }; void main() { clrscr(); result r; r.accepts(); r.acceptt(); r.displays(); r.displayr(); getch(); } OUTPUT Enter Roll no and name101 ABC Enter two marks87 76

Roll no and name:101 ABC Total: 163

EXP10_3 INPUT #include<iostream.h> #include<conio.h> #include<string.h> class product { char id[10],name[20]; public: void acceptp() { cout<<"Enter the product id and name"; cin>>id>>name; } void displayp() { cout<<"\nProduct id and name"<<id<<"\t"<<name<<endl; } }; class edible:public product { char flavor[20]; int price,weight; public: void accepte() { cout<<"Enter Weight";

cin>>weight; cout<<"Enter Price"; cin>>price; cout<<"Enter Flavor"; cin>>flavor; strupr(flavor); }

void displaye() { if(strcmp(flavor,"SWEET")==0) { displayp(); cout<<"Weight"<<weight<<endl; cout<<"Price"<<price<<endl; } } }; void main() { clrscr(); edible e; e.acceptp(); e.accepte(); e.displaye(); getch(); }

OUTPUT Enter the product id and nameI006 BARFI Enter Weight2 Enter Price600 Enter Flavorsweet

Product id and nameI006 BARFI Weight2 Price600

EXP 10_4 INPUT #include<iostream.h> #include<conio.h> class medicine { char company[20],name[20]; public: void acceptm() { cout<<"Enter company and name of the medicine"; cin>>company>>name; } void displaym() { cout<<"Company:\t"<<company<<"\nName:\t"<<name; } }; class dealer:public medicine { public: char prodname[20]; int price; void acceptd() { cout<<"Enter product name and its price medicine"; cin>>prodname>>price;

} }; class retailer:public dealer { float sell; public: void display() { sell=0.015*price; sell=sell+price; displaym(); cout<<"Product name:\t"<<prodname<<endl; cout<<"Selliing price:\t"<<sell; } }; void main() { clrscr(); retailer r; r.acceptm(); r.acceptd(); r.display(); getch(); } OUTPUT: Enter company and name of the medicineDr_Morepen Lemolate

Enter product name and its price medicine LEmolate_gold 100 Company: Dr_Morepen

Name: LemolateProduct name: LEmolate_gold Selliing price: 101.5