Help with getting input from .DAT file, putting it into an array all within a function.

I was given this .DAT file
Volmer 88 90 177 172 180 194
Wilson 191 213 276 288 305 320
Mandich 270 299 302 325 376 401
Pinto 109 132 150 167 178 189
Mcmahon 122 127 143 155 168 188
Miller 95 102 110 238 128 155
Hemple 34 53 54 38 92 97
Bonner 86 56 101 124 136 144
Sayers 153 134 142 141 185 192
Franks 56 62 77 83 90 93

I am supposed to take the data here for each sales associate and put the names into a string array, and each of their monthly sales totals into a two dimensional array. As well as using the 6 months of data to calculate the 6 month average of each associate, and put them into an array as well. I am confused on how to do this within a function, which is the requirement.

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
  #include <iostream>
#include <fstream>
using namespace std;
void getData( string names[], int Signup_Data[][6], int count);

int main() {
    fstream file ("Proj12.DAT");
    int Signup_Data[10][6];
    int Signup_Avg [10];
    string names [10];
    
    if (file.is_open())
    {
        file << "File successfully opened";
       
    }
    else
    {
        cout << "Error opening file";
    }
    getData(names, Signup_Data, 10);
    
    return 0;
}
void getData( string n[], int Signup_Data[][6], int count)
{
    for (int i = 0; i < count; ++i)
    {
        file << names[i] << Signup_Data[][i];
    }
}


and I must output this:

RAC 6 Month Sales Associate Performance Report

Associate Jan Feb Mar Apr May June Sign-up Average

Volmer 88 90 177 172 180 194 150

Wilson 191 213 276 288 305 320 266

Mandich 270 299 302 325 376 401 329

Pinto 109 132 150 167 178 189 154

McMahon 122 127 143 155 168 188 151

Miller 95 102 110 238 128 155 138

Hemple 34 53 54 38 92 97 61

Bonner 86 56 101 124 136 144 108

Sayers 153 134 142 141 185 192 158

Franks 56 62 77 83 90 93 77

6 month average: 159

Last edited on
Topic archived. No new replies allowed.