2000 :
2.b) Define a class worker with the following specification.
Private member of class worker:
wname 25characters
hrwrk,wgrate float (hours worked and wagerate per hour)
totwage float(hrwrk*wgrate)
cakcwg() A function to find hrwrk*wgrate
with float return type
Public members of class worker:
In_data( ): A function to accept values forwno, wname, hrrwrk, wgrate and invoke
calcwg( ) to calculate totpay.
Out_data( ): A function to display all the data members on the screen you should give definitions of functions.
class worker
{ char wname[25];
float hrwrk,wgrate;
float totwage;
float cakcwg( )
{ return hrwrk*wgrate;
}
public:
void In_data( )
{ cout<<”\nEnter Worker number,name,hoursworked and wage rate”;
cin>>wno;
gets(wname);
cin>>hrwrk>>wgrate;
calcwg( );
}
void Out_data( )
{ cout<<”\nThe Worker Number: “<<wno;
cout<<”\nThe Name of the worker: “<<wname;
cout<<”\nNumber of hours worked by the worker: “<<hrwrk;
cout<<”\nThe Wage Rate of the Worker: “<<wgrate;
cout<<”\nThe total wages of the worker: “<<totwage;
}4
1999 :
2.b) Define a class Teacher with the following class specification:
Private members:
Name 20 characters
Subject 10 characters
Basic, DA, HRA float
Salary float
Calculate( ) function computes the salary and returns it. Salary is sum of Basic, DA and HRA
CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )