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 1, 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 2).

Espresso Yourself’s Coffeehouse Payroll Program – Part 2

This is a continuation of last week’s program. Which means you better update last weeks program to be correct and work. And remember it is NOT ok for you to use the Module 2 solution as your starting point for this assignment!

This week’s requirements:

  1. All of the input data must be in a file
    1. The employee’s name
    2. Followed by their hours
  2. All of the output data displayed will be formatted
    1. Names 10 blank spaces in between
      1. Left justified
      2. 20 spaces to hold the name
    2. Monthly pay
      1. Right justified
      2. Always show the decimal place and 2 digits after it for the cents
      3. 9 spaces to hold the monthly pay
      4. Include the $ before the 9 spaces, not part of it
      5. Fill the empty space between the number and the $ with * (the asterisk)
  3. Add the owners salary
    1. Liza Bossert
    2. Salaried - $75,000.00 / year
    3. For the owner you will show her monthly salary first and separately
    4. Titled “Owner’s Salary”
    5. Followed by 5 blank spaces
    6. 10 formatted spaces for the pay
    7. Rest of the formatting, use the same as the rest of the employees

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

Existing code from part 1:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

struct employee {
   string first_name, last_name;
   int hours[4], weeks;
   int total_hours;
   double hour_pay;
   double salary;
} emp[100];

int main()
{
   emp[0].first_name = "Darren";
   emp[0].last_name = "Duchesne";
   emp[1].first_name = "Christian";
   emp[1].last_name = "Cargile";
   emp[2].first_name = "Selena";
   emp[2].last_name = "Dresher";
   emp[3].first_name = "Neil";
   emp[3].last_name = "Palafox";
   emp[4].first_name = "Emilia";
   emp[4].last_name = "Rogge";
   emp[5].first_name = "Jamie";
   emp[5].last_name = "Lanphear";

   cout << "Espresso Yourself's Coffehouse\n";
   cout << "------------------------------\n";
   cout << "Enter details for Hourly employees: \n";
   cout << emp[0].first_name << " " << emp[0].last_name << ":\n";
   cout << "Pay per hour: ";
   cin >> emp[0].hour_pay;
   cout << "Hours worked: ";
   cout << "Week 1: ";
   cin >> emp[0].hours[0];
   cout << "Week 2: ";
   cin >> emp[0].hours[1];
   cout << "Week 3: ";
   cin >> emp[0].hours[2];
   cout << "Week 4: ";
   cin >> emp[0].hours[3];
   cout << emp[1].first_name << " " << emp[1].last_name << ":\n";
   cout << "Pay per hour: ";
   cin >> emp[1].hour_pay;
   cout << "Hours worked: ";
   cout << "Week 1: ";
   cin >> emp[1].hours[0];
   cout << "Week 2: ";
   cin >> emp[1].hours[1];
   cout << "Week 3: ";
   cin >> emp[1].hours[2];
   cout << "Week 4: ";
   cin >> emp[1].hours[3];
   cout << emp[2].first_name << " " << emp[2].last_name << ":\n";
   cout << "Pay per hour: ";
   cin >> emp[2].hour_pay;
   cout << "Hours worked: ";
   cout << "Week 1: ";
   cin >> emp[2].hours[0];
   cout << "Week 2: ";
   cin >> emp[2].hours[1];
   cout << "Week 3: ";
   cin >> emp[2].hours[2];
   cout << "Week 4: ";
   cin >> emp[2].hours[3];
   cout << emp[3].first_name << " " << emp[3].last_name << ":\n";
   cout << "Pay per hour: ";
   cin >> emp[3].hour_pay;
   cout << "Hours worked: ";
   cout << "Week 1: ";
   cin >> emp[3].hours[0];
   cout << "Week 2: ";
   cin >> emp[3].hours[1];
   cout << "Week 3: ";
   cin >> emp[3].hours[2];
   cout << "Week 4: ";
   cin >> emp[3].hours[3];

   cout << "Salaried Employees:\n";
   cout << emp[4].first_name << " " << emp[4].last_name << ":\n";
   cout << "Pay per annum: ";
   cin >> emp[4].salary;
   cout << "Weeks worked: ";
   cin >> emp[4].weeks;
   cout << emp[5].first_name << " " << emp[5].last_name << ":\n";
   cout << "Pay per annum: ";
   cin >> emp[5].salary;
   cout << "Weeks worked: ";
   cin >> emp[5].weeks;

   emp[0].total_hours = emp[0].hours[0] + emp[0].hours[1] + emp[0].hours[2] + emp[0].hours[3];
   emp[1].total_hours = emp[1].hours[0] + emp[1].hours[1] + emp[1].hours[2] + emp[1].hours[3];
   emp[2].total_hours = emp[2].hours[0] + emp[2].hours[1] + emp[2].hours[2] + emp[2].hours[3];
   emp[3].total_hours = emp[3].hours[0] + emp[3].hours[1] + emp[3].hours[2] + emp[3].hours[3];


   cout << "\n\n-----------------------------\n";
   cout << "Payroll for the month\n";
   cout << "Hourly Employees:\n";
   cout << "First Name Last Name\tHours Worked\tGross Pay\n";
   cout << emp[0].first_name << " " << emp[0].last_name << "\t\t" << emp[0].total_hours << "\t" << emp[0].hour_pay*emp[0].total_hours << "\n";
   cout << emp[1].first_name << " " << emp[1].last_name << "\t" << emp[1].total_hours << "\t" << emp[1].hour_pay*emp[1].total_hours << "\n";
   cout << emp[2].first_name << " " << emp[2].last_name << "\t" << emp[2].total_hours << "\t" << emp[2].hour_pay*emp[2].total_hours << "\n";
   cout << emp[3].first_name << " " << emp[3].last_name << "\t" << emp[3].total_hours << "\t" << emp[3].hour_pay*emp[3].total_hours << "\n";

   cout << "Salaried Employees:\n";
   cout << "First Name Last Name\tWeeks Worked\tGross Pay\n";
   cout << emp[4].first_name << " " << emp[4].last_name << "\t" << emp[4].weeks << "\t" << emp[4].weeks*emp[4].salary / 48 << "\n";
   cout << emp[5].first_name << " " << emp[5].last_name << "\t" << emp[5].weeks << "\t" << emp[5].weeks*emp[5].salary / 48 << "\n";

   return 0;
}

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