Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Open the source code file named Payroll.cpp using Notepad or the text editor

ID: 3679768 • Letter: 1

Question

1. Open the source code file named Payroll.cpp using Notepad or the text editor of your choice.

2. Variables have been declared and initialized for you as needed, and the input and outputstatementshavebeenwritten. Readthecodecarefullybeforeyouproceedtothenextstep.

3. Write the C++ code needed to perform the following:a. Calculate state withholding tax at 6.5 percent, and calculate federal withholdingtax at 28.0.b. Calculate dependent deductions at 2.5 percent of the employee ’ s salary for eachdependent.c. Calculate total withholding. (Total withholding is the total state withholdingcombined with the total federal withholding.)d. Calculate take-home pay as salary minus total withholding plus deductions.

4. Save this source code file in a directory of your choice, and then make that directory your working directory.

5. Compile the program.

6. Execute the program.

You should get the following output:

State Tax: $81.25

Federal Tax: $350

Dependents: $62.5

Salary: $1250

Take-Home Pay: $881.25

7. In this program, the variables salary and numDependents are initialized with the values 1250.00 and 2. To make this program more flexible, modify it to acceptinteractive input for salary and numDependents .

Name the modified version Payroll2.cpp .

Explanation / Answer

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

               

                string name;

                cout << "Enter your name: " << endl;

                getline (cin, name);

               

                double gross;

                cout << "Enter gross amout: " << endl;

                cin >> gross;

               

                cout << fixed << setprecision(2) << endl;

               

                cout << name << endl;

               

                cout << left << "Gross Amount: "<< right << setw(13) << setfill('.') << " $" << gross << endl;

               

                double federal = gross*0.28;

                cout << "Federal Tax: ............. $ " << federal << endl;

               

                double state = gross*0.065;

                cout << "State Tax: ............... $ " << state << endl;

                //for two dependents

                double dependents= gross*0.025*2;

               

cout << "depndents: ......... $ " << dependents << endl;

               

                double net = gross-(federal+state)+dependents;

                cout << "Net Pay: Take home pay................. $" << net << endl;

               

                return 0;

}