8. Three employees in a company are up for a special pay increase. You are given
ID: 3620242 • Letter: 8
Question
8. Three employees in a company are up for a special pay increase. You are given a file, Ch3_Ex8Data.txt, with the following dataMiller Andrew 65789.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1
Each input line consists of the employee's last name, first name, current salary, and precent pay increase. Write a program that reads data from the specified file and stores the output in the file Ch3_Ex8Output.dat. For each employee the days must be output in the following form: firstName, lastName, updatedSalary. Format the ouput of the decimal numbers to two decimal places.
Explanation / Answer
please rate - thanks #include <iostream>#include <fstream>
#include <iomanip>
using namespace std;
int main()
{string first,last;
double salary,rate,updated;
ifstream in;
ofstream out;
in.open("Ch3_Ex8Data.txt"); //open file
if(in.fail()) //is it ok?
{ cout<<"file did not open please check for it's existance program aborting ";
system("pause");
return 1;
}
out.open("Ch3_Ex8Output.dat");
out<<" Updated ";
out<<" First Last Salary ";
out<<"------------------------------------ ";
in>>first;
while(in)
{in>>last>>salary>>rate;
updated=salary+(salary*(rate/100.));
out<<first<<" "<<last<<" $"<<setprecision(2)<<fixed<<updated<<endl;
in>>first;
}
in.close();
out.close();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.