PROGRAMMING PROBLEMS

4. Modify the program of Problem 3 so that it also computes and displays the employee’s net pay. Net pay is gross pay minus deductions. Assume that deductions are taken for tax withholding (30% of gross pay) and parking ($10 per month).

Answers

#include using namespace std; int main () { double hours, rate, gross_pay, deductions, net_pay; cout << "Enter the number of hours worked: "; cin >> hours; cout << "Enter the hourly rate: "; cin >> rate; gross_pay = rate * hours; deductions = ((gross_pay * 0.30) + 10.0); net_pay = gross_pay - deductions; cout << "Gross Pay: $" << gross_pay << endl; cout << "Deductions: $" << deductions << endl; cout << "Net pay: $" << net_pay << endl; return 0; } The code simply adds a line of code to calculate the employee's deductions and then another line to calculate their net pay by subtracting the deductions from the gross pay. Finally, it displays the deductions and net pay amounts.

Answered by aarongreen

We have mentors from

Contact support