how would i finish this

Started by
14 comments, last by Ravuya 17 years, 1 month ago
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. Format your output to have two decimal places> A sample output follows: The program should produce this type of output both on the display monitor and to a data file c:\lab5_data.txt. John Doe Gross Amount: ………… $3575.00 Federal Income Tax: ……. $ 536.25 State Tax: …………. ……. $ 125.13 Social Security Tax: ……… $ 205.56 Medicare/Medicaid Tax: .. $ 98.33 Pension Plan: ……………...$ 178.75 Health Insurance: …………. $ 75.00 Net Pay ……………………. $2356.00 Note that the first column is left-justified and the right column is right-justified. so far i have this #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { string name; double income, federal, state; income, federal=income*15,state=(income*3.5); cout<<fixed<<showpoint; cout<<setprecision(2); cout<<"what is your name?"<<endl; cin>>name; cout<<"gross income?"<<endl; cin>>income; cout<<"federal income tax:"<<income*.15<<endl; cout<<"state tax:"<<income*3.5<<endl; return 0; }
Advertisement
I would probably output this to PDF, HTML or a spreadsheet format, first of all, as text is usually a bad way of representing tabular information. At best, I'd use a CSV format for importing somewhere else. And, anyways, your accounting department probably has its own document template to print its paychecks, so you should look into compatibility with that.

Either way, this looks more like a job for a script language (such as PERL or PHP, maybe Python) or, even better, a spreadsheet macro. Is there any reason why you want to do this in C++?
well im doin this in school in visual studio 6.0
I'm afraid this forum has a pretty negative stance on homework questions. Though you have my deepest sympathies for having to use Visual C++ 6.
Quote:Original post by jj71787
well im doin this in school in visual studio 6.0


NOOOOO!!!!!!

Please tell me you are not using VS6.0 at your school.

It's so old, it's old.

income, federal=income*15,state=(income*3.5);


huh? Please explain to me what you are trying to do on this line.
yea they make us use it
Well, we're not going to write it for you. Do you have any specific question about the problem? [Edit: As always, the best person to ask is your instructor.]
Moved to For Beginners.
i didnt ask you to write it for me i said if you look at the numbers the federal tax comes out right when it calculates income*.15 but the state tax doesnt work it comes out to 12510.50 instead od 125.13
Quote:Original post by jj71787
i didnt ask you to write it for me i said if you look at the numbers the federal tax comes out right when it calculates income*.15 but the state tax doesnt work it comes out to 12510.50 instead od 125.13


No, when did you ever ask a single question.... The topic title is "how would I finish this"

Find me a single question that you asked... Aside from the problem statement from the homework?

You are off by a factor of 100 - look at what you are multiplying by.

This topic is closed to new replies.

Advertisement