CSE1002 Special Pay Increase Problem
Employees in a company are up for a special pay increase. Given a file, with each line consisting of an employee's last name, first name, current salary, and percent pay increase, write a C++ program to compute the revised pay of each employee.Miller Andrew 65875.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1.
For example, the pay increase for Andrew is 5%.
UML:
CODE:
void employee::get(ifstream &f)
{
f>>firstName;
f>>lastName;
f>>salary;
f>>inc;
}
void employee::update_Sal()
{
updated_Salary=salary+salary*inc/100;
}
void employee::print()
{
cout<<firstName<<endl<<lastName<<endl<<fixed<<setprecision(2)<<updated_Salary<<endl;
}
int main()
{
char s[100];
ifstream f;
cin>>s;
f.open(s,ios::in);
employee e[100];
int i=0;
while(!f.eof())
{
e[i].get(f);
e[i].update_Sal();
e[i].print();
i++;
}
return 0;
}
No comments:
Post a Comment