Hi everyone! I'm very new to C++ (this is my first semester). I have to create a payroll program using classes that will read from a file (contains employee name, ID, hours worked, and wage), calculate the salary, and display employee name, ID, and salary.
Please help me revise my code. Any suggestions/ input will be helpful. Thank you!
#include "Payroll.h"
Payroll::Payroll(string n, int i, double hours, double wage)
{
name = n;
ID = i;
hoursWorked = hours;
wages = wage;
int main ()
{
ifstream myFile;
myFile.open("Project 3.dat");
if (myFile.fail())
{
cout <<"File not found!"<< endl;
}
else
{
int count = 0;
Payroll p;
while (!myFile.eof()) {
string foo;
switch (count) {
case 0:
p.set_name(foo);
break;
case 1:
p.set_ID(stoi(foo));
break;
case 2:
p.set_hoursWorked(stod(foo));
break;
case 3:
p.set_wages(stod(foo));
break;