Вы находитесь на странице: 1из 13

#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.

h> class play { int playcode; char playtitle[25]; float duration; int noofscenes; public: play() { duration=45; noofscenes=5; } void newplay() { cin>>playcode; gets(playtitle); } void moreinfo(float x, int y) { duration=x; noofscenes=y; } void showplay() { cout<<playcode; cout<<playtitle; cout<<duration; cout<<noofscenes; } }; #include<iostream.h> #include<conio.h>

#include<string.h> #include<stdio.h> class travelplan { long plancode; char place[25]; int no_of_travellers; int no_of_busses; public: travelplan() { plancode=1001; strcpy(place,"agra"); no_of_travellers=5; no_of_busses=1; } void newplan() { cin>>plancode; gets(place); cin>>no_of_travellers; if(no_of_travellers<20) no_of_busses=1; else if((no_of_travellers>=20)&&(no_of_travellers<40) no_of_busses=2; else if(no_of_travellers>=40) no_of_busses=3; } void showplan() { cout<<plancode; cout<<place; cout<<no_of_travellers; cout<<no_of_busses; } }; #include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h>

class serial { int serialcode; char title[25]; float duration; int noofepisodes; public: serial() {duration=30; noofepisodes=10; } void newserial() {cin>>serialcode; gets(title); } void otherentries(float x, int y) { duration=x; noofepisodes=y; } void dispdata() { cout<<serialcode; cout<<title; cout<<duration; cout<<noofepisodes; } };

#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> class clothing

{ char code[20]; char type[20]; char material[20]; int size; float price; void calc_price() { if (strcmp(material,"cotton")==0) { if(strcmp(type,"trouser")==0) price=1500; else if(strcmp(type,"shirt")==0) price=1200; } else if(strcmp(type,"trouser")==0) price=(1500-(25*15)); else if(strcmp(type,"shirt")==0) price=(1200-(25*12)); public: clothing() { strcpy(code,"not assigned"); strcpy(type,"not assigned"); strcpy(material,"not assigned"); size=0; price=0; } void Enter() { gets(code); gets(type); gets(material); cin>>size; calc_price(); } void show() cout<<code;

cout<<type; cout<<material; cout<<size; cout<<price; } };

#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> class outfit { char Ocode[20]; char Otype[20]; char Ofabric[20]; int Osize;

float Oprice; void initprice() { if (strcmp(Ofabric,"denim")==0) { if(strcmp(Otype,"trouser")==0) Oprice=1500; else if(strcmp(Otype,"shirt")==0) Oprice=2500; } else if(strcmp(Otype,"trouser")==0) Oprice=(1500-(25*15)); else if(strcmp(Otype,"shirt")==0) Oprice=(2500-(25*25)); public: outfit() { strcpy(Ocode,"not initialised"); strcpy(Otype,"not initialised"); strcpy(Ofabric,"not initialised"); Osize=0; Oprice=0; } void Input() { gets(Ocode); gets(Otype); gets(Ofabric); cin>>Osize; initprice(); } void display() cout<<Ocode; cout<<Otype; cout<<Ofabric; cout<<Osize; cout<<Oprice; } };

#include<iostream.h> #include<conio.h> #include<stdio.h> class publication { char title[20]; float price; public: getdata1() { cout<<"Enter the title : "; gets(title); cout<<"\n"<<"Enter the price : ";

cin>>price; } putdata1() { cout<<"Title : "<<title<<"\n"; cout<<"Price : "<<price<<"\n"; } }; class book:public publication { int pages; public: void getdata() { getdata1(); cout<<"Enter the no of pages : "; cin>>pages; } void putdata() { putdata1(); cout<<"No of pages : "<<pages<<"\n"; } };

class tape:public publication { float playtime; public: void getdata() { getdata1(); cout<<"Enter the play time :"; cin>>playtime; } void putdata() { putdata1(); cout<<"Play time : "<<playtime<<"\n"; } }; void main() { clrscr(); char choice; book bk; tape tp; cout<<"You wanna buy books or tape (b/t) : "; cin>>choice; if(choice=='b'||choice=='B') { bk.getdata(); bk.putdata(); } if(choice=='t'||choice=='T') { tp.getdata(); tp.putdata(); }

getch(); }

#include<iostream.h> #include<conio.h> #include<stdio.h> class account { char name[20]; int accno; public: float newbal; float openbal; void getdata1() { newbal=0; cout<<"Enter the account no :"; cin>>accno; cout<<"Enter the name : "; gets(name);

cout<<"Enter the opening balance : "; cin>>openbal; } void putdata1() { cout<<"Account no : "<<accno<<"\n"; cout<<"Name : "<<name<<"\n"; cout<<"Opening Balance : "<<openbal<<"\n"; cout<<"Total Balance : "<<newbal<<"\n"; } }; class current:public account { public: void getdata(); }; void current::getdata() { getdata1(); int b; clrscr(); cout<<"1 Deposit . "; cout<<"2. Withdraw . "; cout<<"Enter your choice : "; cin>>b; switch(b) { case 1: { int a,b; cout<<"Enter the amount to deposit : "; cin>>a; newbal=a+openbal; putdata1(); break; } case 2: { int a; float b; cout<<"Enter the amount to withdraw : "; cin>>a; newbal=openbal-a; if(newbal<1000) { b=0.1*newbal; cout<<"\n"<<"Penalty : "<<b<<"\n"; } putdata1(); } } } class saving: public account {public:

void getdata(); }; void saving::getdata() { getdata1(); int b; clrscr(); cout<<"1 Deposit . "; cout<<"2. Withdraw . "; cout<<"Enter your choice : "; cin>>b; switch(b) { case 1: { int a; float b; cout<<"Enter the amount to deposit : "; cin>>a; newbal=a+openbal; b=0.1*newbal; newbal=newbal+b; putdata1(); break; } case 2: { int a; float b; cout<<"Enter the amount to withdraw : "; cin>>a; newbal=openbal-a; b=.1*newbal; newbal=b+newbal; putdata1(); } } } void main() {clrscr(); current curr; saving sav; char choice; cout<<"Current or Saving (c/s): "; cin>>choice; if(choice=='c') { curr.getdata(); } if(choice=='s') { sav.getdata(); } getch(); }

class student { char name[10]; int age; public: readData() display() }; class primarystudent:public student { int noofhr; public: void ReadPrimary() DisplayPrimary() }; class secondarystd:public student { }; class book:public student { char bookname; int noofpages; public:

ReadB() displayB() }; class equipment:public secondarystd { char name; int role; public: ReadEquip(); Display(); };

Вам также может понравиться