Dongxiao Gross Amount: ............ $1000.00 Federal Tax: ............. $ 150.00 State Tax: ............... $ 35.00 Social Security Tax: ..... $ 57.50 Medicare/Medicaid Tax: ... $ 27.50 Pension Plan: ............ $ 50.00 Health Insurance: ........ $ 75.00 Net Pay: ................. $ 605.00
#include <iostream> #include <string> #include <iomanip> using namespace std; //Experimenting with this, but didn't work out //const char* text = "Constant text "; //const size_t MAXWIDTH = 14; // //void print(const string& var_text, int num) //{ // cout << text // // align output to left, fill goes to right // << left << setw(MAXWIDTH) << setfill('.') // << var_text << ": " << num << '\n'; //} int main() { string name; int x; double FedIncTax, //Federal Income Tax StateTax, //State Tax SSTax, //Social Security Tax MedTax, // Medicare/Medicaid Tax PenPlan, //Pension Plan HealthIns = 75, //Health Insurance GrossAmnt, //Gross amount NetPay; //Net Pay //Input cout<<"Enter your name: "; cin>>name; cout<<"Enter your Gross amount: "; cin>>GrossAmnt; //Calculations FedIncTax = (GrossAmnt * 0.15); StateTax = (GrossAmnt * 0.035); SSTax = (GrossAmnt * 0.0575); MedTax = (GrossAmnt * 0.0275); PenPlan = (GrossAmnt * 0.05); NetPay = GrossAmnt - (FedIncTax + StateTax + SSTax + MedTax + PenPlan + HealthIns); //Output cout<< name <<endl; cout<<fixed<<setprecision(2); cout<<"Gross Amount: "<<setfill('.')<<setw(14)<<" $"<<GrossAmnt<<endl; cout<<"Federal Tax: "<<setfill('.')<<setw(15)<<" $"<<FedIncTax<<endl; cout<<"State Tax: "<<setfill('.')<<setw(17)<<" $"<<right<<StateTax<<endl; cout<<"Social Security Tax: "<<setfill('.')<<setw(7)<<" $"<<right<<SSTax<<endl; cout<<"Medicare/Medicaid Tax: "<<setfill('.')<<setw(5)<<" $"<<right<<MedTax<<endl; cout<<"Pension Plan: "<<setfill('.')<<setw(14)<<" $"<<right<<PenPlan<<endl; cout<<"Health Insurance: "<<setfill('.')<<setw(10)<<" $"<<right<<HealthIns<<endl; cout<<"Net Pay: "<<setfill('.')<<setw(19)<<" $"<<right<<NetPay<<endl; return 0; }
(25 points) Write a program that calculates and prints the monthly paycheck for an employee. The net pay is calculated after taking the following deductions: Federal Income Tax: 15% State Tax: 3.5% Social Security Tax: 5.75% Medicare/Medicaid tax: 2.75% Pension Plan: 5% Health Insurance: $75.00 Your program should prompt the user to input the gross amount and the employee name. The output will be stored in a file. Format your output to have two decimal places. Your output should be formatted to two columns. The first column is left-justified, and the right column is right-justified.