1. Engineering
  2. Computer Science
  3. i need help with this c assignment i have completed...

Question: i need help with this c assignment i have completed...

Question details

I need help with this C++ assignment, I have completed Part 2, I will post below the instructions and modifications needed to be added to my existing code. My existing code will be below the instructions for my current assignment (part 3). Please provide the txt file and format if you use one. Thank you!

Espresso Yourself’s Coffeehouse Payroll Program – Part 3

This is a continuation of last week’s program. Which means AGAIN you better update last weeks program to be correct and work.

This week’s requirements:

All of the employee’s, Hourly or Salaried, wage information will be retrieved from the file
Additionally, the user will be asked about tips for each individual except the owner
There may or may not be any tips for the week
Ask for each person about tips
The tips, for the week, will be added to the employee’s gross pay
BUT, not to the company total for wage expenses
There needs to be an additional column for the tips and a total for each employee
Show zero’s if there was no entry of tips for that week

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

Existing code from part 2:

#include "stdafx.h"
#include
#include
#include
#include
#include
using namespace std;
//Headers display
void display1();
void display2();
//Employee deatails storing struct
struct employee {
   string first_name, last_name;
   int hours[4], weeks;
   int total_hours;
   double hour_pay;
   double salary;
} emp[100];
//Main method
int main()
{
   //File read object
   ifstream in;
   //Variable to get read line's count
   int i = 0;
   //File path
   in.open("EmployeeDetails.txt");
   //Check opening error
   if (!in) {
       cout << "File can't be open" << endl;
       exit(0);
   }
   //If open read corresponding data
   else {
       while (!in.eof()) {
           if (i <= 3) {
               in >> emp[i].first_name >> emp[i].last_name >> emp[i].hour_pay >> emp[i].hours[0] >> emp[i].hours[1] >> emp[i].hours[2] >> emp[i].hours[3];
               i++;
           }
           else {
               in >> emp[i].first_name >> emp[i].last_name >> emp[i].salary >> emp[i].weeks;
               i++;
           }

       }
   }
   //for calculating employee total hours for hourly payers
   for (int j = 0; j < i; j++) {
       if (j <= 3) {
           emp[j].total_hours = emp[j].hours[0] + emp[j].hours[1] + emp[j].hours[2] + emp[j].hours[3];
       }
   }
   //Display formatted output
   for (int j = 0; j < i; j++) {
       //Owner details and first header
       if (j == 0) {
           cout << "Espresso Yourself's Coffehouse";
           cout << "\n------------------------------\n";
           cout << "Payroll for the month";
           cout << "\n------------------------------\n";
           cout << "Owner's Salary:" << endl;
           cout << "\nName Hours Worked Gross Pay \n";
           cout << left << setw(20) << setfill(' ') << "Liza Bossert" " " << " $" << right << setw(9) << setfill('*') << (75000.00 / 48) * 11 << " ";
           display1();
       }
       //Last header
       else if (j == 4) {
           display2();
       }
       //Display hourly pay employee details
       if (j <= 3) {
           cout << left << setw(20) << setfill(' ') << emp[j].first_name + " " + emp[j].last_name << " " << emp[j].total_hours;
           cout << " " " $" << right << setw(9) << setfill('*') << emp[j].hour_pay*emp[0].total_hours << " \n";
       }
       //Display salaried person details
       else {

           cout << left << setw(20) << setfill(' ') <            cout << " " " $" << right << setw(9) << setfill('*') << emp[j].weeks*emp[4].salary / 48 << " \n";
       }
   }

   return 0;
}
//Header display functions
void display1() {
   //cout << "\n------------------------------\n";
   cout << "\n\nHourly Employees: ";
   cout << "\nName Hours Worked Gross Pay \n";
}
void display2() {
   cout << "\nSalaried Employees: ";
   cout << "\nName Weeks Worked Gross Pay \n";;
}

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

File used

Darren Duchesne 40 8 8 8 8
Christian Cargile 35 4 5 6 7
Selena Dresher 50 3 4 5 6
Neil Palafox 25 5 6 4 8
Emilia Rogge 4000 40
Jamie Lanphear 3000 42

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution