Reading and calculating data from file

My goal is to calculate payroll based on information from a file. I need to distinguish between hourly and salary employees and apply overtime and taxes. I think I have the formulas and if statements correct (though if anyone wants to look at them any help is greatly appreciated). My biggest problem is opening the file and figuring out how to get my program to recognize the different columns of information. Here is a portion of the data file. The first column is employee ID followed by H or S for hourly and salary followed by annual salary or hours and rate of pay. I am completely lost on where to go from here. I barely understand how to open the file let alone how to get my program to read and assign the values to the appropriate variables. I don't mind changing my variable names if I need to. Any help that you guys can give me will be very appreciated.

101456 H 20 6.57
100045 S 81994.12
100321 H 45 23.50
101987 H 39 15.76
100486 S 116935.65

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
//This program will calculate payroll

#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;

int main()
{

//Variables
double grosspay;
double overtimepay;
double netpay;
double taxes;
int empID;
char code;
double hours;
double rate;
double OThours;
OThours = 0;
//Open File

ifstream fileIn;

//inFile.open ("payData.txt");
fileIn.open ("payData.txt"); //Open file

//Grosspay Calculations

if (code = 's')
		grosspay = grosspay / 52;

if (code = 'h')
	if (hours <= 40)
	{
		grosspay = hours * rate;
	}
	else OThours = hours - 40;
		grosspay = (OThours * rate * 1.5) + ((hours - OThours) * rate);

//Tax calculations

if (grosspay < 925)
	netpay = grosspay * 0.85;

else if (grosspay >= 925 && grosspay < 2860)
	netpay = (grosspay - 925) * 0.72 + (925 - 138.75);

else if (grosspay >= 2860 && grosspay < 4100)
	netpay = (grosspay - 2860) * 0.68 + (2860 - 680.55);

else if (grosspay > 4100)
	netpay = grosspay * 0.60;

cout << grosspay;
system ("Pause");
return 0;
}
Topic archived. No new replies allowed.