Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(C++) using VSExpress17 write a program: Three employees in a company are up for

ID: 3878810 • Letter: #

Question

(C++) using VSExpress17

write a program:

Three employees in a company are up for a special pay increase. You are given a file, say Ch3_Ex6Data.txt, with the following data:

Miller Andrew 65789.87 5

Green Sheila 75892.56 6

Sethi Amit 74900.50 6.1

Each input line consists of an employee’s last name, first name, current salary, and percent pay increase.

For example, in the first input line, the last name of the employee is Miller, the first name is Andrew, the current salary is 65789.87, and the pay increase is 5%.

Write a program that reads data from the specified file and stores the output in the file Ch3_Ex6Output.dat.

For each employee, the data must beoutputinthefollowingform:firstNamelastName updatedSalary.

Format the output of decimal numbers to two decimal places.

Explanation / Answer

PLEASE REFER BELOW CODE

#include<iostream>

#include<fstream>

#include<string>

#include <iomanip> // std::setprecision

using namespace std;

//creating structure for employee

typedef struct Employee

{

string last_name,first_name;

double cur_salary, per_pay;

}Employee;

int main()

{

//stream for output file

ofstream outfile;

//stream for input file

ifstream infile;

Employee E;

//opening input file

infile.open("Ch3_Ex6Data.txt");

//if file is absent

if(!infile)

{

cout<<"Error in opening file"<<endl;

return 0;

}

//creating output file

outfile.open("Ch3_Ex6Output.dat");

//if fail to create file

if(!outfile)

{

cout<<"Error in creating file"<<endl;

return 0;

}

//reading input file line by line

while(infile >> E.last_name >> E.first_name >> E.cur_salary >> E.per_pay)

{

//writing to output file

outfile<<E.first_name<<" "<<E.last_name<<" "<<fixed<<setprecision(2)<<(E.cur_salary + (E.per_pay * 0.01 * E.cur_salary))<<endl;

}

return 0;

}

//creating output file

outfile.open("Ch3_Ex6Output.dat");

//if fail to create file

if(!outfile)

{

cout<<"Error in creating file"<<endl;

return 0;

}

//reading input file line by line

while(infile >> E.last_name >> E.first_name >> E.cur_salary >> E.per_pay)

{

//writing to output file

outfile<<E.first_name<<" "<<E.last_name<<" "<<fixed<<setprecision(2)<<(E.cur_salary + (E.per_pay * 0.01 * E.cur_salary))<<endl;

}

return 0;

}

INPUT FILE IS Ch3_Ex6Data.txt

Miller Andrew 65789.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1

OUTPUT FILE IS Ch3_Ex6Output.dat.

Andrew Miller 69079.36
Sheila Green 80446.11
Amit Sethi 79469.43