I am completly lost with arrays. I have scoured my book and the exaamples it gives are way to simple. I can wrerite them like those in the books, but I cannot seem to get the real problem to work. Also I am doing ifstream and ofstream so I cannot really see what is happening. I printed to screen once and it was just a bunch of garbage. Here is the problem: I have to take input from the file PianoREV.data and output it to Report.out. I need to setup parallel partially filled arrays for the contestant id's, student level, composision difficulty rating, num judges and overall averages. I need two dimensional arrays for the judge ids judges scores and weighted scores. Then a print report fucntion comes and prints it all. I have not attempted to write this as i cannot get the arrays to work to begin with. Here is an example of the PianoREV.
6010 1 1.3
23 7.0
25 8.5
34 7.0
12 7.5
-1
6012 1 1.2
23 7.5
34 7.0
45 7.0
50 7.5
-1
The first number is the player id. the second the proficiency level, the third is the weight factor, followed by judge and then score. I had a lot of help with psuedo code on the first assignment based on this task and would depply appreciate some more. MY teacher is really not helping any of us. Half the class has dropped and the other half is failing. Anyways here is what i have so far. Am I even going in the right direction?
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
const int MAXMEMBERS = 25;
int ReadScores (ifstream& fin, int pianoPlayer[MAXMEMBERS], double score[MAXMEMBERS]);
int pianoPlayer[MAXMEMBERS];
double score[MAXMEMBERS];
double weightFactor[MAXMEMBERS];
int profLevel[MAXMEMBERS];
const int MAXJUDGES = 7;
int main()
{
ifstream fin;
ofstream fout;
fin.open("PianoREV.data");
if (fin.fail())
{
cout << "Error: Input File";
exit (1);
}
fout.open("Report.out");
if (fout.fail())
{
cout << "Error: Output File";
exit (1);
}
ReadScores (fin, pianoPlayer, score);
fin.close();
fout.close();
}
int ReadScores (ifstream& fin, int pianoPlayer[MAXMEMBERS], double score[MAXMEMBERS])
{
int countPlayers = 0;
while (countPlayers < MAXMEMBERS && (fin >> pianoPlayer[MAXMEMBERS]))
{
int i = 0;
int judgeNumber[i];
fin >> profLevel[countPlayers];
fin >> weightFactor[countPlayers];
while (judgeNumber[i] != -1)
{
for(i = 0; i<MAXJUDGES;i++)
{
fin >> judgeNumber[i];
fin >> score[i];
fin >> judgeNumber[i];
}
}
}
return countPlayers;
}