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

Write a C++ program which prompts the user for an employee\'s full name and annu

ID: 3671596 • Letter: W

Question

Write a C++ program which prompts the user for an employee's full name and annual salary and then outputs paycheck information. A sample program execution would be as follows :

Please enter the emplyee's full name : Amanda M. Swanson.

Please enter the employee's yearly salary : 42500

    Weekly Paycheck Information

Name : Amanda M. Swanson          Annual Gross : 42,500.00

Weekly Gross :   $      817.30

Federal Tax :     $       114.42

State Tax :          $         38.82

Medicare :           $         18.79

Social Sec :        $         57.21

Health Ins.  :        $       128.31

401K           :        $          89.90     

------------------------------------------     

Net Pay     :         $        369.85             

NOTE : Here are relevant items to consider when designing and coding the program  :    

A.  Note the employee full name has spaces in it. Therefore, the getline function can be used instead of using 3 separate variables( for first name, MI, and

     last name).

B. Global constants can be used for the deduction percentages :

     ie :   const double Fedtax = 0.14;

     The percentages for other deductions are :

      State Tax = 4.75 %

      Medicare = 2.3 %

      Social Sec = 7 %

      Health Care = 15.7 %

      401K = 11 %

C. All monetary amounts must be decimal aligned as shown on the output with 2 decimal places. (Use setprecision manipulator)

Explanation / Answer

#include <iostream>
#include <iomanip>

using namespace std;

//global constants

const double Fedtax = 0.14;
const double State_Tax = 0.0475;
const double Medicare = 0.023;
const double Social_Sec = 0.07;
const double Health_care = 0.157;
const double K401= 0.11;


int main()
{
string name;
double salary,weekly,net_pay;

cout<<"Please enter employee's full name:: ";
getline(cin, name);
cout<<"Please enter employee's yearly salary:: ";
cin>>salary;


weekly = salary/52.0;   //conversion into weekly salary

cout<<" Weekly Paycheck Information ";
cout<<"Name: "<<name<<" Annual Gross : "<<salary<<endl<<endl;

cout.setf(ios::fixed, ios::floatfield); // set fixed floating format
cout.precision(2); // for fixed format, two decimal places
net_pay = weekly*(1-(Fedtax+State_Tax+Medicare+Social_Sec+Health_care+K401));
cout<<"Weekly Gross : $"<<setw(6)<<weekly<<" "<<endl;
cout<<"Federal Tax : $"<<setw(6)<<weekly*Fedtax<<" "<<endl;
cout<<"State Tax : $"<<setw(6)<<weekly*State_Tax<<" "<<endl;
cout<<"Medicare : $"<<setw(6)<<weekly*Medicare<<" "<<endl;
cout<<"Social Sec : $"<<setw(6)<<weekly*Social_Sec<<endl;
cout<<"Health Ins : $"<<setw(6)<<weekly*Health_care<<endl;
cout<<"401K   : $"<<setw(6)<<weekly*K401<<endl;
printf("--------------------------------- ");
cout<<"Net Pay : $"<<setw(6)<<net_pay<<endl;

return 1;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote