Computer Science, asked by pathakshobha300033, 10 months ago

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 bindidevi002
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