basic 2 dimensional arrays and function

Hi, im new to the forums and am trying to do a project for school. I just cant seem to figure out what im doing wrong and my teacher is never available to talk to so I figure why not give this forum a shot =]

my program is supposed to set up 3 separate arrays; the first is a 2 dimensional array involving the first 2 columns of the data file, the 2nd is a 1 dimensional array with data from the 3rd columns of the data file, and the last array is supposed to calculate the corresponding rows total and add 45% commision onto the total. there is a lot more things that need to be done with formatting and more random arithmetic but i am capable enough to manage that on my own, just the arrays+the functions throw me off. any help or pointers would be greatly appreciated.


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
TR17-Red-Blue-Green  tricycle  24.98
TR12-Red-Blue   tricycle  21.95
BY12-Red-Boys   bicycle   107.98
BY12-Red-Pink-Girl  bicycle   107.95
BY24-Blue-Black-Boys  Bicycle   134.96
BY24-Blue-Pink-Girls  Bicycle   134.95
BY27-Blue-Black-Boys  Bicycle   156.96
BY27-Blue-Pink-Girls  Bicycle   156.00
WA6742-Red   Wagon   23.97
PY342-set   My_Little_Pony  34.56
PS657909-Set   Pet_Shop  27.95
LL8236587-Train-Set  Train   237.55
FT675432-98   Fire_Truck  45.00
RC92819-56   Radio_Control_Car 98.00
AG908776-Baby   American_Girl_Baby_Doll 60.00
AG456924-Girl   American_Girl-Doll 90.00
PH85639-567   Doll_House  70.00
GA8325456-M   Monopoly  12.00
GA3418856-S   Sorry   10.00
GA7666552_T   Trivia   24.95
BA7822221-BB   Basketball  9.00
BA9834226-BA   Baseball  6.00
BA7845558-VB   Volley_Ball  9.00
BA4527719-SB   Soccer_Ball  9.00
BB4519677-BT   Baseball_Bat  12.00


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
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
const int ARRAYSIZE = 25;


int main(int argc, char *argv[])
{
    ifstream infile;
    infile.open("default.txt");
    string toys[ARRAYSIZE][2]= {" "};
    double wholesale[ARRAYSIZE]= {0.0};
    double price[ARRAYSIZE]= {0.0};

    cout << fixed << showpoint << setprecision(2);
    
    if(!infile)
    {
              cout << "error";
              system("PAUSE");
              return 1;
    }
     int row=0;
     int col=0;
    while(infile)
    {        
                 infile >> toys[row][0] >> toys[row][1];
                 cout << setfill(' ') << left << setw(30)<< toys[row][0] ;
                 cout << setfill(' ') << left << setw(20)<< toys[row][1] ;
                      
  
                 for(row = 0; row < 25; row++)
                 {
                         infile >> wholesale[row];
                         cout <<setw(25) << wholesale[row] << " ";
                         cout << endl;
                         
                 }
                 cout << endl;      
                 row++;          
    }//End of while
    col = col - 1;        

    system("PAUSE");
    return EXIT_SUCCESS;
}


Topic archived. No new replies allowed.