I need some advice on how to get past a huddle in my Homework. I am to write C++ program to read the file and display the results with appropriate formatting. Read from the file a person’s name, SSN, and wage, the number of hours worked in a week, and his or her status and store it in appropriate multidimensional arrays.So far I can read from the file into a string array containing the person's first name, last name and SSN. However I can't seem to figure out to integrate a second multidimensional array to capture the wage, hours worked.
1.
#include <iostream>
2.
#include <fstream>
3.
#include <string>
4.
usingnamespace std;
5.
6.
int main()
7.
{
8.
string file[5][10];
9.
double payInformation[5][10];
10.
char eStatus;
11.
double overTimePay, regularPay, netPay;
12.
13.
14.
ifstream fin("data.txt");
15.
16.
if (fin.fail())//Check if the file is open
17.
{
18.
cout << "File not opened..." << endl;
19.
return 1;
20.
}
21.
while (!fin.eof())
22.
{
23.
if (!fin.eof())
24.
{
25.
for ( int i = 0; i < 5; i++ ) // loop through the 1st dimension of the array
26.
for ( int j = 0; j < 3; j++ ) // loop through the 2nd dimension of the array
27.
fin >> file[i][j]; // read to each element of the array
28.
}
29.
}
30.
31.
32.
33.
34.
fin.close();
35.
36.
37.
system ("PAUSE");
38.
return 0;
39.
}