Calculating Net Pay

Hi all, I am a complete noob when it comes to programming but anyway, I am writing a program for class that calculates Net pay from Gross Pay after deductions. The program is suppose to save all input data to an outside file but there is no data being input from an outside source. I keep getting this error code
1>Build started 2/17/2012 12:43:39 PM.
1>InitializeBuildStatus:
1> Touching "Debug\MonthlyPayCheck.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Sleek Super Beast\Documents\Visual Studio 2010\Projects\MonthlyPayCheck\Debug\MonthlyPayCheck.exe : fatal error LNK1120: 1 unresolved externals

I am using Microsoft Visual Studio 2010 here is the code I have written:

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

using namespace std;

int main ()
{
ofstream outFile;

string FullName;
int GrossAmnt;
double FedTax = .15;
double StateTax = .035;
double SSTax = .0575;
double MedTax = .0275;
double Penpl = .05;
int HInsur = 75.00;

outFile.open ("MonthlyPay.txt")

outFile << " Enter Full Name: ";
cin >> FullName;
outFile << endl;

outFile << setprecision (2); // setprecision to 2 for the rest of the document unless otherwise specified
outFile << " Enter Gross Amount: ";
cin >> GrossAmnt;
outFile << endl;

outFile << left;
outFile << FullName << endl;
outFile << setfill ('.') << setw (20) << "Gross Amount:" << right << " $" << setw (6) << GrossAmnt << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Federal Tax:" << right << " $" << setw (6) << GrossAmnt * FedTax << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "State Tax:" << right << " $" << setw (6) << GrossAmnt * StateTax << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Social Security Tax:" << right << " $" << setw (6) << GrossAmnt * SSTax << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Medicare/Medicaid Tax:" << right << " $" << setw (6) << GrossAmnt * MedTax << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Pension Plan:" << right << " $" << setw (6) << GrossAmnt * Penpl << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Health Insurance:" << right << " $" << setw (6) << HInsur << endl;

outFile << left;
outFile << setfill ('.') << setw (20) << "Net Pay" << right << " $" << setw (6) << GrossAmnt - (GrossAmnt * FedTax) - (GrossAmnt * StateTax) - (GrossAmnt * SSTax) - (GrossAmnt * MedTax) - (Gross Amnt * Penpl) - HInsur << endl;

outFile.close (); //Not necessary
system ("pause")
return 0;
}

In the future please post code in the code tag
So...much...[ code ] [ /code]...fail...
My bad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

int main ()
{
	ofstream outFile;

	string FullName;
	int GrossAmnt;
	double FedTax = .15;
	double StateTax = .035;
	double SSTax = .0575;
	double MedTax = .0275;
	double Penpl = .05;
	int HInsur = 75.00;

	outFile.open ("MonthlyPay.txt")

	outFile << " Enter Full Name: "; 
	cin >> FullName; //Uses the string Identifier to notify program it is more than one character
	outFile << endl;

	outFile << setprecision (2); // setprecision to 2 for the rest of the document unless otherwise specified
	outFile << " Enter Gross Amount: ";
	cin >> GrossAmnt;
	outFile << endl; 

	outFile << left; 
	outFile << FullName << endl;
	outFile << setfill ('.') << setw (20) << "Gross Amount:" << right << " $" << setw (6) << GrossAmnt << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Federal Tax:" << right << " $" << setw (6) << GrossAmnt * FedTax << endl; 
	
	outFile << left; 
	outFile << setfill ('.') << setw (20) << "State Tax:" << right << " $" << setw (6) << GrossAmnt * StateTax << endl; 

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Social Security Tax:" << right << " $" << setw (6) << GrossAmnt * SSTax << endl;

	outFile << left; 
	outFile << setfill ('.') << setw (20) << "Medicare/Medicaid Tax:" << right << " $" << setw (6) << GrossAmnt * MedTax << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Pension Plan:" << right << " $" << setw (6) << GrossAmnt * Penpl << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Health Insurance:" << right << " $" << setw (6) << HInsur << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Net Pay" << right << " $" << setw (6) << GrossAmnt - (GrossAmnt * FedTax) - (GrossAmnt * StateTax) - (GrossAmnt * SSTax) - (GrossAmnt * MedTax) - (Gross Amnt * Penpl) - HInsur << endl; 

	outFile.close (); //Not necessary
	system ("pause")
	return 0;
} 


is that better?
As a general rule, whenever I get an "unresolved symbol" dealing with anything, I check to see if the thing I'm referring to actually exists. Try this:
1
2
3
4
if(outFile.bad()){
    cerr << "Unable to open file for writing!" << endl;
    return 1;
}
Thanks! Apparently the project I was using it under was bugged. Anyway I have a new issue with the same program, it won't actually do any of my calculations, when I debug it all that appears is a black blank screen, I input two things and it prompts me to press any key to continue and closes. How do I get the program to perform the way I want it too?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

int main ()
{
	ofstream outFile;

	string FullName;
	int GrossAmnt;
	double FedTax = .15;
	double StateTax = .035;
	double SSTax = .0575;
	double MedTax = .0275;
	double Penpl = .05;
	int HInsur = 75.00;

	outFile.open ("MonthlyPay.txt");

	outFile << " Enter Full Name: "; 
	cin >> FullName; //Uses the string Identifier to notify program it is more than one character
	outFile << endl;

	outFile << setprecision (2); // setprecision to 2 for the rest of the document unless otherwise specified
	outFile << " Enter Gross Amount: ";
	cin >> GrossAmnt;
	outFile << endl; 

	outFile << left; 
	outFile << FullName << endl;
	outFile << setfill ('.') << setw (20) << "Gross Amount:" << right << " $" << setw (6) << GrossAmnt << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Federal Tax:" << right << " $" << setw (6) << GrossAmnt * FedTax << endl; 
	
	outFile << left; 
	outFile << setfill ('.') << setw (20) << "State Tax:" << right << " $" << setw (6) << GrossAmnt * StateTax << endl; 

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Social Security Tax:" << right << " $" << setw (6) << GrossAmnt * SSTax << endl;

	outFile << left; 
	outFile << setfill ('.') << setw (20) << "Medicare/Medicaid Tax:" << right << " $" << setw (6) << GrossAmnt * MedTax << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Pension Plan:" << right << " $" << setw (6) << GrossAmnt * Penpl << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Health Insurance:" << right << " $" << setw (6) << HInsur << endl;

	outFile << left;
	outFile << setfill ('.') << setw (20) << "Net Pay" << right << " $" << setw (6) << GrossAmnt - (GrossAmnt * FedTax) - (GrossAmnt * StateTax) - (GrossAmnt * SSTax) - (GrossAmnt * MedTax) - (GrossAmnt * Penpl) - HInsur << endl; 
  
	system ("pause");
	return (0);
}
  

I want to input Full name and then Gross amount then I need the program to do the proper calculations, what am I doing wrong?
Looks like it's doing what you told it to. You don't have any output to the terminal, only to the file. Look inside the file and see what you have in there. ;)
okay so obviously its saving it to the file, how do I get it to output to the terminal? Use cout instead of outFile?
Yes.
Got it! thanks!
Topic archived. No new replies allowed.