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

https://elearning.sharjah.ac.ae/bbcswebdav/pid-1014001-dt-content-rid-1418762 1/

ID: 3597440 • Letter: H

Question

https://elearning.sharjah.ac.ae/bbcswebdav/pid-1014001-dt-content-rid-1418762 1/courses/14111 Problem 4: Monthly Paycheck Write a C+ program that calculates and prints the monthly paycheck for an employe. The net pay is calculated after taking the following deductions: Federal Income Tax: 15t State Tax: 3.5% Social Security Tax : 5.75% Medicare/Medicaid Tax: 2.75% Pension Plan: 5% Health Insurance: $75.00 The program should prompt the user to input the gross amount (of salary) and the employee name. Format your output on the screen to have two decimal places Hint you can use setar and setpraision in order to solve this problem Sample input / output: ter enployee nane Mr.Ahnad ter gross anount: 23568 r.Ahnad Gross Anount: $23568.80 3534.8 824.68 Social Security Tax 1354-78 647.98 Pension Plan:1178.88 Pederal Tax: State Tax: Medicare Medicaid Tax: Health Insurance: Net Pay: $15945.88

Explanation / Answer

Caluculate employee net pay:

=============================

#include<iostream>

using namespace std;

int main()

{

float Grass_amount=0,Net_pay=0, Fedaral_tax=0, State_tax=0, Social_security_tax=0,Medicare_tax=0,Pension_plan=0,Helth_insurence=75;

char name[100];

cout<<"Enter the name of Employee : ";

cin >> name;

cout<<"Enter Grass amount of Employee : ";

cin>>Grass_amount;

cout<<name<< std::endl;

cout<<"Grass amount:"<<Grass_amount<< std::endl;

Fedaral_tax=Grass_amount*0.15;

cout<<"Fedaral_tax : "<<Fedaral_tax<< std::endl;

State_tax=Grass_amount*0.035;

cout<<"State_tax : "<<State_tax << std::endl ;

Social_security_tax=Grass_amount*0.0575;

cout<<"Social_security_tax : "<<Social_security_tax<< std::endl;

Medicare_tax=Grass_amount*0.0275;

cout<<"Medicare_tax : "<<Medicare_tax<< std::endl;

Pension_plan=Grass_amount*0.05;

cout<<"Pension_plan : "<<Pension_plan<< std::endl;

  

Net_pay=Grass_amount-(Fedaral_tax+State_tax+Social_security_tax+Medicare_tax+Pension_plan)-Helth_insurence;

cout<<"Net_pay : "<<Net_pay;

return 0;

}

Headsn and Tails simulation:

============================

#include<iostream>

#include<cstdlib>

using namespace std;

int flip();

int main ()

{

int coin, counter, tails = 0, heads = 0,n=0;

cout<<"Enter How meny coins you want to tossed : ";

cin >> n;

  

for (counter = 1; counter <= n; counter++)

{

coin = flip ();

if(coin == 0)

{

cout<<"T ";

tails = tails + 1;

}

else if( coin == 1)

{

cout<<"H ";

heads = heads + 1;

}

}

cout<<endl;

cout<<"Tails was tossed "<<tails<<" times"<<endl;

cout<<"Heads was tossed "<< heads<<" times"<<endl;

}

int flip()

{

return rand( ) % 2;

}