Help Please! Keep getting errors.

Please Help! I need get my code to work with my notepad file that is payrollCalc. Not sure what I am doing wrong.

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  //The Payroll Calculator program to enter specific data
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using namespace std;

//Function prototypes
void ReadInputData(ifstream& In, string& empName, double& empId, double& hWorked, double& choice, 
	double& employeeType, double& insDeduct, double& cont401k);
void CalculateGrossPay(double& hWorked, double& hRate, double& cont401k);
void CalculateTaxDeductions(double& grossPay, double& FIT, double& FICA, double& SIT, double& FMED,
	 double& insDeduct, double& choice);
void CalculateNetPay(double& netPay, double& grossPay, double& FIT, double& FICA, double& FMED, double& SIT, double& insDeduct);
//Prints out the employee's pay stub
void WriteOutputData(string& empId, string& empName, double& grossPay, double& FIT, double& FICA,
	double& SIT, double& insDeduct, double& cont401k, double& netPay);

//Tax Rate by Code...
const double FICArate = 0.062;
const double FMEDrate = 0.0145;
const double SITrate = 0.05;
const double FITrate = 0;
//Paycode by rate...
const double Mrate = 27.50;
const double Crate = 19.50;
const double Lrate = 10.35;
//Insurance Code
const double Acode = 25.00;
const double Bcode = 15.00;
const double Ccode = 0.00;
//Tax Bracket for FIT
const double Bracket1 = 0.125;
const double Bracket2 = 0.22;
const double Bracket3 = 0.2935;
//Contribution to 401k set at $150 deduction from grosspay
const double cont401k = 150.00;

void main()
{
	//Variable declaration
	string empName;
	string empId = 0;
	double hWorked = 0;
	double hRate = 0;
	double oTime = 0;
	double grossPay = 0;
	double cont401k = 0;
	double insDeduct = 0;
	double FIT = 0;
	double FICA = 0;
	double SIT = 0;
	double FMED = 0;
	double netPay = 0.0;
	char employeeType;
	double choice;
	ifstream inFile;
	ofstream outFile;
		
	inFile.open("PayrollCalc.txt"); //Open the input file.

		while (!inFile.eof())
		{
		//Input information for Employee
		outFile << setw(empName.length() + 1);
		inFile >> empName;

		outFile << "Enter Employee ID: ";
		inFile >> empId;

		outFile << "ENTER THE HOURS WORKED: ";
		inFile >> hWorked;

		outFile << "Enter Employee Type: ";
		outFile << "M or m (a manager employee),";
		outFile << "C or c (a contractor employee),";
		outFile << "L or l (a level employee),";
		inFile >> employeeType;

		outFile << "A or a ($25.00 Insurance Deduction)," << endl;
		outFile << "B or b ($15.00 Insurance Deduction)," << endl;
		outFile << "C or c ($0.00 Insurance Deduction)," << endl;
		inFile >> choice;

		switch (employeeType)
		{
			//Manager Hourly Pay Rate
		case 'm':
		case 'M':
			hRate = Mrate;
			break;
			//Contrator Hourly Pay Rate
		case 'c':
		case 'C':
			hRate = Crate;
			break;
			//Level Hourly Pay Rate
		case 'l':
		case 'L':
			hRate = Lrate;
			break;
		default:
			hRate = Lrate;
		}

		if (choice == 'A')
			insDeduct = 25.00;
		if (choice == 'B')
			insDeduct = 15.00;
		if (choice == 'C')
			insDeduct = 0.00;

		outFile.open("paystub.out");

		//Caculates employee regular pay with overtime.
		//The first 8 hours are calculated at hRate + 50%.
		//Any hours beyond are double time + grosspay.

		CalculateGrossPay(hWorked, hRate, cont401k);

		if (hWorked <= 40)
		{
			grossPay = (hRate * hWorked) - cont401k;
		}

		if (hWorked > 40 && hWorked <= 48)
		{
			grossPay = (40 * hRate) + (hWorked - 40)*(hRate*1.5)-cont401k;
		}

		if (hWorked > 48)
		{
			grossPay = 40 * hRate + 8 * 1.5 * hRate + (hWorked - 48) * 2.0 * hRate - cont401k;
		}

		CalculateTaxDeductions(grossPay, FIT, FICA, FMED, SIT, insDeduct,choice);

		if (grossPay > 0 && grossPay < 350.00)
			FIT = (grossPay * Bracket1);

		if (grossPay > 350.00 && grossPay < 1000.00)
			FIT = (grossPay * Bracket2);


		if (grossPay > 1000.00)
			FIT = (grossPay * Bracket3);
		else

		FICA = FICArate * grossPay;
		FMED = FMEDrate * grossPay;
		SIT = SITrate * grossPay;
		insDeduct = choice - grossPay;

		CalculateNetPay(netPay, grossPay, FIT, FICA, FMED, SIT, insDeduct);

		netPay = grossPay - FIT - FICA - FMED - SIT - insDeduct;

		
		WriteOutputData(empId, empName, grossPay, FIT, FICA, FMED, SIT, cont401k, insDeduct);
		
		outFile << "----------------------------------------------------------" << endl;

		outFile << "ID    Name       Gross    FIT     FMED     FICA     SIT     401k    Ins     Net" << endl << endl;
		outFile << setw(6) << empId;
		outFile << fixed << showpoint;
		outFile << setw(10) << setprecision(2) << empName
			<< setw(9) << setprecision(2) << grossPay
			<< setw(7) << setprecision(2) << FIT
			<< setw(6) << setprecision(2) << FICA
			<< setw(6) << setprecision(2) << FMED
			<< setw(6) << setprecision(2) << SIT
			<< setw(5) << setprecision(2) << cont401k
			<< setw(8) << setprecision(2) << insDeduct
			<< setw(9) << setprecision(2) << netPay
			<< endl;
		outFile << endl;
		outFile << "--------------------------------------------------" << endl;

		//Loop termination
		outFile << "Do you want to exit (n/y)" << endl;
		
	}
	inFile.close();
	outFile.close();

	return;
}
closed account (48T7M4Gy)
It's not unusual for people who post here to want their programs to run.
However it is unusual for people to not give even a small clue why they think their program is not operating to their satisfaction.

So with that in mind, aside from your very comprehensive listing, you might like to give us more information. Perhaps an error summary, what output you expected vs what output you got if any. Even a clue where you think it might be because surely problems only occurred after a block of code was written rather than your only attempt at running the program was after all 188 lines were typed in.

At the moment your program won't run because void main should be int main and return should be return 0 or some other int value. But, and I can only guess, your experience of the problems you are having goes deeper than that. :)
closed account (48T7M4Gy)
Please don't double post
Topic archived. No new replies allowed.