Class news {
int m=2,total,c;
float n=1.50;
void getdata()
{
cout<<”Enter the code”:
cout<<”\n 0 for morning”
cout<<”\n 1 for evening”;
cin>>c;
cout<<”\nEnter the total paper rounds in a week”;
cin>>total;
}
};
class earnings extends news{
int e=0;
void compute(){
if(c==0)
e=total*m;
if(c==1)
e=total*n;
}
void display () {
cout<<”The boy earnings is”<<e;
}};
void main () {
earnings e1;
e1.getdata ();
e1.compute ();
e1.display ();
} |