Sign in to follow this  
jj71787

how would i finish this

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
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++?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I see you use the setprecision() manipulator, you will also be wanting the setw() manipulator to help you get at least 1 of those justifications you want.

Share this post


Link to post
Share on other sites
You seem to have to basic idea on what to do, perhaps you're just confused about the formatting aspect of the assignment? I will say it's a pain in the neck to do formatting in C++, but here are some links that may help:
Very informative, probably a little too complex:
http://www.arachnoid.com/cpptutor/student3.html
Just a list of all i/o flags and manipulators. Doesn't explain their usage, but you can experiment!
http://www.cppreference.com/io_flags.html
A page of a few i/o flags and manipulators with an example:
http://www.fredosaurus.com/notes-cpp/io/omanipulators.html

Hope some of them help.

Share this post


Link to post
Share on other sites
yea im only learning basic programming i know a little about the basics but still need to learn more thats y i came here figured i could alot from people here but very few people are willing to help

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this