Question

Program 3. Decisions Due: Friday, February 7 by 11:59 PM Overview For this program, design a...

Program 3. Decisions
Due: Friday, February 7 by 11:59 PM


Overview

For this program, design a wage calculator for a single user. The program will use the user's number of hours worked and their hourly wage to calculate:

  • Gross Pay
  • Deduction
  • Net Pay

The Gross Pay is the amount that the user is paid before any deduction is applied. The pay amount is based upon the number of hours worked. If 40 hours or less were worked, the gross pay is equal to number of hours worked times the hourly wage. If more than 40 hours were worked, the gross pay is equal to the pay for the first 40 hours worked plus overtime pay, which is for any hour over 40 and is paid at 1.5 times the hourly wage for each hour over 40.

The Deduction is based on the user's gross pay. If the user earned $100.00 or less, the deduction is 2% of the gross pay. If the user earned between $100.01 and $500.00, the deduction is 5% of the gross pay. If the user earned $500.01 or more, the deduction is 9% of the gross pay.

The Net Pay is equal to the gross pay minus any deduction.

Basic Program Logic

The program should ask the user for the number of hours that they worked (integer) and their hourly wage (float or double).

Using a decision statement, calculate the gross pay for the user.

Using a second decision statement, calculate the user's deduction.

Calculate the net pay for the user.

Finally, display the wage information in a table. It should include the number of hours worked, hourly wage, gross pay, deduction, and net pay.

Program Requirements

  1. At the top of the C++ source code, include a documentation box that resembles the one from programs 1 and 2. This will be a part of every program that is submitted during the semester and this will be the last reminder in the program write-ups.

  2. Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does. This will also be a part of every program that is submitted for the remainder of the semester.

  3. The dollar amounts should all be displayed with exactly 2 digits after the decimal point, including zeros.

  4. Make sure and test the program with values other than those in the sample output.

  5. Hand in a copy of the source code (CPP file ONLY) using Blackboard.

Output

A few runs of the program should produce the following results:

Run 1

How many hours did you work? 57
How much are you paid per hour? 5.75


Wage Calculator

Hours Worked                   57
Hourly Wage                  5.75
---------------------------------

Gross Pay                  376.62
Deductions                  18.83
---------------------------------

Net Pay                    357.79


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

wage.cpp

#include <iostream>

using namespace std;

int main()

{

// Storing Number Of Hours Worked

int workHour;

// Storing Hourly Rate

double hourWage;

double grossPay;

double deduction;

double netPay;

cout << "How many hours did you work?\n";

cin >> workHour;

cout << "How much are you paid per hour?\n";

cin >> hourWage;

if(workHour<=40){

grossPay = workHour * hourWage;

}

else if(workHour>40){

// Calculating Overtime Hours

int overTimeHour = workHour - 40;

// Calculating Overtime Wage

double overTimeWage = overTimeHour * 1.5 * hourWage;

// Work Hour at normal wage would be Total Work Hour less Overtime Hours

grossPay = ((workHour-overTimeHour) * hourWage) + overTimeWage;

}

if(grossPay<=100.00){

// Deduction is 2%

deduction = (grossPay * 2)/100;

}

else if(grossPay>=100.01 && grossPay<500.00){

// Deduction is 5%

deduction = (grossPay * 5)/100;

}

else if(grossPay>=500.01){

deduction = (grossPay * 9)/100;

}

// Net Pay

netPay = grossPay - deduction;

cout << "\n\n\nWage Calculator\n";

cout << "Hours Worked " << workHour << "\n";

printf("Hours Wage %.2lf \n",hourWage); // Printing Upto Two decimal places only using %.2lf

cout << "---------------------------------\n";

printf("Gross Pay %.2lf \n",grossPay);

printf("Deductions %.2lf \n",deduction);

cout << "---------------------------------\n";

printf("Net Pay %.2lf \n",netPay);

return 0;

}

Compilation and Running

To Compile enter the following command : g++ -o wage wage.cpp

To Run enter the following command : ./wage

Screenshot Of Working Output

Output 1

Output 2

Please let me know in the comments if any additions are needed.

Please rate.

Add a comment
Know the answer?
Add Answer to:
Program 3. Decisions Due: Friday, February 7 by 11:59 PM Overview For this program, design a...
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
  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview...

    Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...

  • A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who...

    A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and “time-and-a-half,” i.e. 1.5 times their hourly wage, for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce-each pieceworker in this company works on only one...

  • The following program MUST be written in Flowgorithm and MUST use modules. Could someone please add...

    The following program MUST be written in Flowgorithm and MUST use modules. Could someone please add screenshots to show me how this is supposed to look in Flowgorithm? I'm confused as to how to break it up into extra functions. For the programming problem, create the flowchart and enter it into the Flowgorithm program to test the accuracy of your logic. Save the file as Ch7Lab1. Payroll Program with Input Validation Design a payroll program that prompts the user to...

  • Acme Parts runs a small factory and employs workers who are paid one of three hourly...

    Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift, $17 per hour; second shift, $18.50 per hour; third shift, $22 per hour. Each factory worker might work any number of hours per week; any hours greater than 40 are paid at one and one-half times the usual rate. In addition, second- and third-shift workers can elect to participate in the retirement plan for which 3% of...

  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user...

    Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user for type of employee (hourly ("h"or "H") or management ("'m" or "M") If the employee is management: . get the annual salary get the pay period (weekly ("w" or "W"), bi-weekly ("b" or "B") or monthly ("m" or e compute the gross salary for the pay period (Divide annual salary by 52 for weekly, 26 for bi-weekly, and 12 for monthly) deduct from gross...

  • This is a Java beginner class. Write the following exercise to check the user inputs to...

    This is a Java beginner class. Write the following exercise to check the user inputs to be: Valid input and positive with using try-catch (and/or throw Exception ) ************************************************************************** Write a program to prompt the user for hours and rate per hour to compute gross pay. Calculate your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Your code should have at least the following methods to calculate the pay. (VOID and...

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