class Bank
{
char name[15];
int acc_no; char acc_type;
float bal_amount;
public: void readData( )
{
cout<<”\nEnter the name: “; gets(name);
cout<<”\nEnter the account number: “;
cin>>acc_no; cout<<”\nEnter the account type: “;
cin>>acc_type;
cout<<”\nEnter the amount to deposit: “;
cin>>bal_amount;
}
void deposit( )
{
float deposit;
cout<<”\nEnter your account number: “;
cin>>acc_no; cout<<”\nEnter the amount to deposit: “;
cin>>deposit; bal_amount=bal_amount + deposit;
}
void withdraw( )
{
float w_amount;
cout<<”\nEnter your account number: “;
cin>>acc_no; cout<<”\nEnter amount to withdraw”;
cin>>w_amount; if((bal_amount-w_amount)<1000)
cout<<”\nWithdraw is not possible”;
else
{
bal_amount=bal_amount-w_amount;
cout<<”\nThe balance is “<<bal_amount-w_amount;
}
}
void display( )
{
cout<<”\nName of the depositor: “<<name;
cout<<”\nAccount Number: “<<acc_no;
cout<<”\nAccount Type: “<<acc_type;
cout<<”\nThe balance amount is “<<bal_amount;
}
};
2000 :
2.b. Define a class worker with the following specification. 4
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 for wno, 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,hours worked 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;
}