#include <iostream>
using namespace std;
class teacher
{
char name[20];
char subject[20];
float basic, da, hra;
public:
void read_data(int i);
void display_data(int i);
int calculate();
};
int teacher ::calculate()
{
if (basic <= 10000)
{
da = basic * 0.8;
hra = basic * 0.2;
}
else if (basic <= 20000)
{
da = basic * 0.95;
hra = basic * 0.25;
}
else
{
da = basic * 0.95;
hra = basic * 0.25;
}
return basic + hra + da;
}
void teacher :: read_data(int i)
{
//cout<<"\n\n***Enter Teacher"<<i<<"Details***";
cout << "Enter the name of the " << i << " Teacher: ";
cin >> name;
cout << "Enter the Subject of the " << i << " Teacher: ";
cin >> subject;
cout << "Enter the basic salary of the " << i << " Teacher: ";
cin >> basic;
}
void teacher :: display_data(int i)
{
int salary = calculate();
cout << i << " Name: "<<name<<endl;
cout <<i << " Subject: "<<subject<<endl;
cout<< i << " Salary: "<<salary<<endl;
}
int main()
{
teacher c[10];
int Not,i;
cout << "How many teacher's data You want to enter: ";
cin>>Not;
for ( i = 0; i <Not ; i++)
{
c[i].read_data(i+1);
cout<<endl;
}
for ( i = 0; i <Not ; i++)
{
c[i].display_data(i+1);
cout<<endl;
}
return 0;
}
Comments
Post a Comment