Question

Your professor is hoping to get a summer job flipping burgers at the local burger joint....

Your professor is hoping to get a summer job flipping burgers at the local burger joint. His starting salary will be $7.25 per hour. However, there are certain incentives to encourage him to work extra hours. It is calculated as follows per day:

•$7.25 for the first 6 hours he works per day, Monday through Friday

.•$8.25 for the next 2 hours he works per day, Monday through Friday.

•$11.25 for each hour he works over 8 hours in a day, Monday through Friday

.•On Saturday and Sunday, his pay is $11.25 per hour regardless of the number of hours he works

.•He will receive an additional $4 per hour bonus for each hour he works over 40 hours in a week.Write a C++ program that will compute the amount of money James would receive for a week's work given the number of hours your professor plans to work each day. Input will be from the keyboard seven positive doubles less than 12 indicating the number of hours, rounded to the nearest half-hour, that James plans to work each day in order, Sunday through Saturday. Output to the screen the amount of money James would make that week in the form $ddd.cc, where d is dollars with no leading zeros and c is cents to the nearest penny (decimal format). Do not use an array. Finally, ask the user if he/she would like to run the program again (upper and lowercase). Refer to the sample output below.

Sample Run:

Enter the hours worked on Sunday: 0

Enter the hours worked on Monday: 5.5

Enter the hours worked on Tuesday:7

Enter the hours worked on Wednesday: 4.5

Enter the hours worked on Thursday: 9

Enter the hours worked on Friday: 10

Enter the hours worked on Saturday: 4

Money earned for the week: $323.00

Play again (Y/N)? Y

Enter the hours worked on Sunday: 9

Enter the hours worked on Monday: 9

Enter the hours worked on Tuesday: 10.5

Enter the hours worked on Wednesday: 8.5

Enter the hours worked on Thursday: 6

Enter the hours worked on Friday: 9

nter the hours worked on Saturday: 0

Money earned for the week: $489.00

Play again (Y/N)? n

Name the program: SummerJobXX.cpp, where XX are your initials

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Files:

SummerJobXX.cpp (where XX are your initials)

#include <iostream>
#include <iomanip>
using namespace std;

double calculateWeekdayEarning(double numHours){

/*
Function to calculate earning for a weekday
*/

double earning;
double forFirst6Hours = 7.25;
double forTheNext2Hours = 8.25;
double after8hours = 11.25;

if(numHours < 0){

cout << "Invalid working hours!";
return 0;
}

if(numHours >= 0 && numHours <= 6){

// $7.25 for the first 6 hours he works per day, Monday through Friday
earning = numHours * forFirst6Hours;

return earning;
}

else if(numHours > 6 && numHours <= 8){

// $8.25 for the next 2 hours he works per day, Monday through Friday

earning = 6 * forFirst6Hours;
earning += (numHours - 6) * forTheNext2Hours;

return earning;
}

else{

// $11.25 for each hour he works over 8 hours in a day, Monday through Friday
earning = 6 * forFirst6Hours;
earning += 2 * forTheNext2Hours;

earning += (numHours - 8) * after8hours;

return earning;
}
}

double calculateWeekendEarning(double numHours){

/*
Function to calculate earning for a weekend
*/

double weekendPay = 11.25;

// On Saturday and Sunday, his pay is $11.25 per hour regardless of the number of hours he works
return numHours * weekendPay;
}

double calculateBonus(double totalHours){

/*
Function to calculate earning as bonus
*/

// Additional $4 per hour bonus for each hour he works over 40 hours in a week

double bonus = 4;

if(totalHours > 40){
return (totalHours - 40) * bonus;
}

else{
return 0;
}
}


int main(){

// flag variable
bool flag = false;

// do-while loop
do{

// choice variable to store user choice to play again.
char choice;

// array and variables to store data received from stdin
double workingHours[7];
double totalHours = 0;
double totalPay = 0;

// reading data from stdin and calculating earning
cout << "Enter the hours worked on Sunday: ";
cin >> workingHours[0];
totalHours += workingHours[0];
totalPay += calculateWeekendEarning(workingHours[0]);

cout << "Enter the hours worked on Monday: ";
cin >> workingHours[1];
totalHours += workingHours[1];
totalPay += calculateWeekdayEarning(workingHours[1]);

cout << "Enter the hours worked on Tuesday: ";
cin >> workingHours[2];
totalHours += workingHours[2];
totalPay += calculateWeekdayEarning(workingHours[2]);

cout << "Enter the hours worked on Wednesday : ";
cin >> workingHours[3];
totalHours += workingHours[3];
totalPay += calculateWeekdayEarning(workingHours[3]);

cout << "Enter the hours worked on Thursday : ";
cin >> workingHours[4];
totalHours += workingHours[4];
totalPay += calculateWeekdayEarning(workingHours[4]);

cout << "Enter the hours worked on Friday : ";
cin >> workingHours[5];
totalHours += workingHours[5];
totalPay += calculateWeekdayEarning(workingHours[5]);

cout << "Enter the hours worked on Saturday : ";
cin >> workingHours[6];
totalHours += workingHours[6];
totalPay += calculateWeekendEarning(workingHours[6]);

// calculate the bonus earned
totalPay += calculateBonus(totalHours);

// printing the results
cout << setprecision (2) << fixed << "Money earned for the week: $" << totalPay << endl;

// prompt to the user
cout << "Play again (Y/N)? " ;
cin >> choice ;

// compare user choice
if(choice == 'Y'){
flag = true;
}

else{
flag = false;
}

}while(flag);
}

output

Enter the hours worked on Sunday: 0
Enter the hours worked on Monday: 5.5
Enter the hours worked on Tuesday: 7
Enter the hours worked on Wednesday : 4.5
Enter the hours worked on Thursday : 9
Enter the hours worked on Friday : 10
Enter the hours worked on Saturday : 4
Money earned for the week: $323.00
Play again (Y/N)? Y
Enter the hours worked on Sunday: 9
Enter the hours worked on Monday: 9
Enter the hours worked on Tuesday: 10.5
Enter the hours worked on Wednesday : 8.5
Enter the hours worked on Thursday : 6
Enter the hours worked on Friday : 9
Enter the hours worked on Saturday : 0
Money earned for the week: $489.00
Play again (Y/N)? N

Hope this helps!

Please let me know if any changes needed.

Thank you!

Add a comment
Know the answer?
Add Answer to:
Your professor is hoping to get a summer job flipping burgers at the local burger joint....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock....

    Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...

  • Complete a time card for the employee below: Adam Spruce (SSN 565-56-5656) worked six days during...

    Complete a time card for the employee below: Adam Spruce (SSN 565-56-5656) worked six days during the week of 01/15/2018 through 01/21/2018 (he was off work on Tuesday). He arrived at 9:00 a.m. each day (except Friday, when he was four minutes early, and Sunday, when he was two minutes late). He left for lunch at 12:30 p.m. each day (except Wednesday, when he left at 12:28 p.m., and Thursday, when he left at 1:01 p.m.), and arrived back at...

  • PYTHON CODE First Code: Write a program that uses a text file to store the daysand...

    PYTHON CODE First Code: Write a program that uses a text file to store the daysand hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line. Sample Output (inputs shown in boldface) How many days did you work this week? 5 Enter...

  • LLC employs only salaried exempt individuals, who work a standard eight hours per day. One of...

    LLC employs only salaried exempt individuals, who work a standard eight hours per day. One of its employees worked more than eight hours on Monday, Wednesday, and Thursday, but did not work more than a total of 40 works during that week. What does FLSA say about the additional hours the employee worked on those single days? The employee will not be paid over time for the extra hours worked on Monday, Wednesday, and Thursday The employee must be paid...

  • So, the brewery selected it’s place and now needs to hire folks. After some testing, they...

    So, the brewery selected it’s place and now needs to hire folks. After some testing, they expect to have approximately 2,000 customers per week. Since they will be open 7 days a week, they need to hire people to help serve their beer. They know that Friday and Saturday will drive sales. Between these 2 days, they will get 50% of their weekly sales. So, Friday has 25% of sales and Saturday has 25% of the sales. As for Sunday...

  • David Thompson- Hourly Rate $14 Hours Worked Saturday Sunday Monday Tuesday Wednesday Thursday Friday 0 2...

    David Thompson- Hourly Rate $14 Hours Worked Saturday Sunday Monday Tuesday Wednesday Thursday Friday 0 2 10 9 7 7 10 All Hours worked in excess of 40 hours for Monday through Friday are paid 1 1/2 times the regular rate. All weekend hours are paid at double the regular rate. What is David Thompson's Gross Pay?

  • THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4...

    THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4 Monday 6 Monday 2 Tuesday 3 Tuesday 2 Wednesday 3 Wednesday 5 Wednesday 7 Thursday 5 Friday 4 Friday 3 Friday 4 Saturday 8 Saturday 8 Saturday 8 Sunday 0 QUESTION: Write the control break code, including the code for the dayChange() method, in the main() method. // SuperMarket.java - This program creates a report that lists weekly hours worked // by employees of...

  • Home U1 02 03 S1 S2 S3 S4 S5 4.1 4.2 4.3 4.4 4.5 4.6 4.7...

    Home U1 02 03 S1 S2 S3 S4 S5 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 Textbook - Help Your Task Write a function pairs(t) to display all pairs of consecutive items from a given tuple t ! Use the docstring Displays all pairs of consecutive items from tuple t""". Expected output: Monday Tuesday Tuesday Wednesday Wednesday Thursday Thursday Friday Friday Saturday Saturday Sunday C Subm Enclab V5.7.33 Predictive Da... Log 4.7 - Predict... Apps Work NCLab Virtual...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • Overall Equipment Effectiveness Exercise for Case Study E Directions: Using your Overall Equipment Effectiveness Calculation Worksheet and th information provided below, determine the Overall Equ...

    Overall Equipment Effectiveness Exercise for Case Study E Directions: Using your Overall Equipment Effectiveness Calculation Worksheet and th information provided below, determine the Overall Equipment a typical Assembly plant for Availability Assumptions: At a typical plant, the constraint in the Widget production process is the machining line. The following information applies to the line for the week of June 5 through June 11. The line was schedulėd to run two &-bour shifts Monday through Friday, and one 9-hour shift on...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT