Question: Hi! I am trying to write a C++ program that reads an input file titled employee.txt and computes and displays a payroll schedule. The intended

Hi! I am trying to write a C++ program that reads an input file titled employee.txt and computes and displays a payroll schedule. The intended output should list a social security number, name, and gross pay for the individuals in the file. My input file looks like this:

Hi! I am trying to write a C++ program that reads an

The values above (left to right) are name, social security number, payment rate per hour, and total number of hours. The final output should look like this:

input file titled employee.txt and computes and displays a payroll schedule. The

In this case, the gross pay is being calculated from multiplying rate and hours together. My output however does not look like this because I am not receiving some values. My received output looks as follows:

intended output should list a social security number, name, and gross pay

I have copied my code below. I dont know what I am missing in order to read the values for the file. If anyone could help it would be greatly appreciated! Thanks!

----------------------------------------

#include

#include /eeded for ifstream and ofstream

#include /eeded for exit()

#include

#include

using namespace std;

int main()

{

string filename = "employee.txt";

ofstream outputFile;

ifstream inFile;

int numEmployees;

int socialSecurity = 0;

string name;

double grossPay = 0, hours = 0, rate = 0;

//determine number of employees

cout

cin >> numEmployees;

inFile.open(filename.c_str()); //create and open file

if (outputFile.fail())

{

cout

exit(1);

}

int i;

inFile.open("employee.txt");

cout

cout

cout

for (int count = 1; count

{

inFile >> name; //Receive employee name

inFile >> socialSecurity; // receive employee SS num

cout

cout

inFile >> rate; // receive employee rate

inFile >> hours; // receive total hours

grossPay = hours * rate; // calculate gross pay

cout

}

inFile.close();

system("pause");

return 0;

}

employee.txt - Notepad Eile Edit Format View Help caldwe11 555-88-2222 7.32 Memcheck 555-88-4444 8. 32 37 4(

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!