Question
Convert your solution to use a while loop to read your file. You need to use the eof() to terminate your loop. #include #include #include
Convert your solution to use a while loop to read your file. You need to use the eof() to terminate your loop.
#include
int main() { ifstream inData; ofstream outData; double salary = 0, percentage = 0; double updatedSalary; char fname [20], lname [20];
cout << "Program that read data from the file:" << "CH03_Ex05Data.txt Store the output in the" << "file: CH03_Ex05.cpp";
inData.open("Ch03_Ex05Data.txt"); outData.open("Ch03_Ex05.cpp");
cout << fixed << showpoint; cout << setprecision(2);
inData >> lname >> fname >> salary >> percentage; updatedSalary = salary * ( 1 + (0.01 * percentage));
outData << "fname" << " " << "lname" << " " << "updatedSalary" << endl; outData << fname << " " << lname << " " << updatedSalary << endl;
inData >> lname >> fname >> salary >> percentage;
updatedSalary = salary * (1 + (0.01 * percentage));
outData << fname << " " << lname << " " << updatedSalary << endl;
inData >> lname >> fname >> salary >> percentage; updatedSalary = salary * (1 + (0.01 * percentage));
outData << fname << " " << lname << " " << updatedSalary << endl;
inData.close(); outData.close(); cout << endl;
system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started