Define a class teacher with the following specifications:
Private members:
Name. 20 characters
Subject. 10 characters
Basic, da ,HRA flot
Salary. Flot.
Answers
Answered by
1
Explanation:
Calculate( ) function computes the salary and returns it. Salary is sum of Basic, DA and HRA
Public members:
ReadData( ): Function accepts the data values and invoke the calculate function.
DisplayData( ):Function prints the data on the screen.
class Teacher
{
char Name[20]; char subject[10];
float Basic,DA,HRA,Salary;
float Calculate( )
{
Salary=Basic+DA+HRA; return Salary;
}
public: void ReadData( )
{
cout<<"\nEnter Basic, Dearness Allowance and “
cout<<” House Rent Allowance: ";
cin>>Basic>>DA>>HRA; Calculate();
}
void DisplayData( )
{
cout<<"\nThe Basic : "<<Basic;
cout<<"\nThe Dearness Allowance: "<<DA;
cout<<"\nThe House Rent Allowance: "<<HRA;
cout<<"\nThe Salary: "<<Salary;
}
};
Similar questions
Hindi,
5 months ago
Science,
5 months ago
Science,
5 months ago
CBSE BOARD XII,
10 months ago
Social Sciences,
10 months ago
English,
1 year ago
Physics,
1 year ago