Simple syntax question

I'm brand new to this and I've ran into a problem. Try not to laugh too hard. I have to write a program that calculates the breakdown of wages but for some reason the output is all zeros. I know it's a syntax problem but I haven't been able to figure it out. Can I have some advice? I don't expect anyone to do my work but I want to know the fundamental problem with my syntax. Thank you.



#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cmath>

using namespace std;

int main()
{
string name = string();
ifstream in;
ofstream out;

in.open("G:\\in.txt");
out.open("G:\\out.txt");


double gross = double();
double fedtax = double();
double statetax = double();
double sstax = double();
double medtax = double();
double pension = double();
double health = double();
double net = double();
double fedt = double();
double statet = double();
double sst = double();
double medt = double();
double pent = double();

fedt = (0.15);
statet = (0.035);
sst = (0.0575);
medt = (0.0275);
pent = (0.05);



fedtax = (gross * fedt);
statetax = (gross * statet);
sstax = (gross * sst);
medtax = (gross * medt);
pension = (gross * pent);
health = (75.00);
net = gross - (fedtax + statetax + sstax + medtax + pension + health);

cout << "Enter first and last name with a space in between:";
getline (cin,name);
cout << "Enter gross pay:";
cin >> gross;

cout << name << endl;
cout << "Gross Amount:" << gross << endl;
cout << "Federal Tax:" << fedtax << endl;
cout << "State Tax:" << statetax << endl;
cout << "Social Security Tax:" << sstax << endl;
cout << "Medicare/Medicaid Tax:" << medtax << endl;
cout << "Pension Plan:" << pension << endl;
cout << "Health Insurance:" << health << endl;
cout << "Net Pay:" << net << endl;


out << name << endl;
out << "Gross Amount:" << gross << endl;
out << "Federal Tax:" << fedtax << endl;
out << "State Tax:" << statetax << endl;
out << "Social Security Tax:" << sstax << endl;
out << "Medicare/Medicaid Tax:" << medtax << endl;
out << "Pension Plan:" << pension << endl;
out << "Health Insurance:" << health << endl;
out << "Net Pay:" << net << endl;


return 0;
}
The calculations are all performed before the gross has been entered by the user. At that time, gross would be zero.

Also, the ifstream, in, is not used.
Last edited on
HAHA. thank you so much for answering this dumb question.
We've all asked dumb questions at one point or another. Glad to help out.
Topic archived. No new replies allowed.