Algorithm: 1. Prompt the user for number of hours. 2. Read the value for hours. 3. Prompt the user for hourly rate. 4. Read the hourly rate. 5. Prompt the user for amount of bonus. 6. Read the value for bonus. 7. Compute the pay. 8. Compute the totalPay by adding bonus to pay. 9. Compute the tax deduction by multiplying 30% times totalPay. 10. Compute the netPay by subtracting tax from totalPay. 11. Neatly print and label the following: a. totalPay b. tax c. netPay Put your program on one of the PCs using a stand alone compiler such as Dev C++, or online compiler such as C++ shell. Name your program salary.cpp and save it on your cloud drive or flash drive after it works. You may write your complete program by hand first and document it as done in the sample class programs. Compile and run your program. It is recommended that you print a copy of your program and put it in your 3-ring binder

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

The Salary Program:

Modify the program from the textbook (Program 1-1,see below) which

  • reads the number of hours an employee works
  • reads the pay rate per hour
  • computes the pay for the employee. 

Add the following steps:

a)    Read an amount of bonus paid to the employee.
b)    Compute the total pay as pay plus bonus.
c)    Compute the tax at 30% of the total pay.
d)    Compute the net pay as total pay minus tax, and

e)    Print a report showing: total pay, tax deduction, and net pay.

 

Algorithm:

1.    Prompt the user for number of hours.
2.    Read the value for hours.
3.    Prompt the user for hourly rate.
4.    Read the hourly rate.
5.    Prompt the user for amount of bonus.
6.    Read the value for bonus.
7.    Compute the pay.
8.    Compute the totalPay by adding bonus to pay.
9.    Compute the tax deduction by multiplying 30% times totalPay.
10. Compute the netPay by subtracting tax from totalPay.
11. Neatly print and label the following:

a.    totalPay

b.    tax

c.    netPay

Put your program on one of the PCs using a stand alone compiler such as Dev C++, or online compiler such as C++ shell. Name your program salary.cpp and save it on your cloud drive or flash drive after it works. You may write your complete program by hand first and document it as done in the sample class programs. Compile and run your program. It is recommended that you print a copy of your program and put it in your 3-ring binder.

 

Program 1-1

// This program calculates the user's pay.

#include <iostream>
using namespace std;

int main()
{
     double hours, rate, pay;

     // Get the number of hours worked.
     cout << "How many hours did you work? ";
     cin >> hours;
  
     // Get the hourly pay rate.
     cout << "How much do you get paid per hour? ";
     cin >> rate;
  
     // Calculate the pay.
     pay = hours * rate;
  
     // Display the pay.
     cout << "You have earned " << pay << endl;
     return 0;
}

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning