L
lsu420luv
'i have been working on this assignment for like 45 hours. the file
reads from Piano.data and outputs into report.out. I have everything
working, except for the fact that it will not repeat until the end of
file is read. It just reads one display. Also the totalScore for each
player seems to come one tenth off every time i run the program. When i
try to call the PrintHigh function it is giving me a undefined
reference. If someone could tell me where I went wrong it would be
great. In the example my teacher gave the while(fin >> pianoPlayer)
read until end of file but in mine wont. Anyways here is an example of
piano.data. this is two players there are 16
6010 1
7.0 8.5 7.0 8.5
7.0 7.5 8.0 7.5
7.5 8.0 7.5 8.0
-1
6012 1
7.5 7.0 9.5 9.0
7.0 6.0 10.0 10.0
7.5 7.5 10.0 9.5
-1
Here is what report.out looks like
Federation of Music Teachers
Mardi Gras Piano Invitational Competition
Baton Rouge, Louisiana
Piano Player: 6010
Level: Primary
Type 1 Type 2 Type 3 Type 4 Overall
Judge 1 7.0 8.5 7.0 8.5 31.0
Judge 2 7.0 7.5 8.0 7.5 23.0
Judge 3 7.5 8.0 7.5 8.0 23.5
Total: 77.3
Here is my code:
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
void SetFormat (ofstream& fout);
void Header (ofstream& fout);
double Process (ifstream& fin, ofstream& fout);
void PrintHigh (ofstream& fout, double highScore);
int main()
{
ifstream fin;
ofstream fout;
double highScore;
fin.open("Piano.data");
if (fin.fail())
{
cout << "ERROR: Input File\n";
exit(1);
}
fout.open("Report.out");
if (fout.fail())
{
cout << "ERROR: Output File\n";
exit(1);
}
SetFormat(fout);
Header(fout);
highScore = Process(fin, fout);
PrintHigh (fout, highScore);
fin.close();
fout.close();
return 0;
}
void SetFormat(ofstream& fout)
{
fout.setf(ios::fixed);
fout.setf(ios:: showpoint);
fout.precision(1);
return;
} // end SetFormat
void Header(ofstream& fout)
{
fout << " \n\n Federation of Music Teachers\n";
fout << " Mardi Gras Piano Invitational Competition\n";
fout << " Baton Rouge, Louisiana\n";
return;
} // end header
double Process(ifstream& fin, ofstream& fout)
{
int numCategories;
int pianoPlayer;
int level;
int judgeNumber;
double scoreType_1, scoreType_2, scoreType_3, scoreType_4;
double highScore = -999999.99;
double score;
double totalScore;
int scoreType;
double sum;
char next;
fin >> numCategories;
while (fin >> pianoPlayer)
{
fin >> level;
judgeNumber = 0;
fout << "Piano Player: ";
fout.width(1);
fout << pianoPlayer << "\n";
fout << "Level: ";
switch(level)
{
case 1:
fout << " Primary\n";
break;
case 2:
fout << " Intermediate\n";
break;
case 3:
fout << " Advanced Intermediate\n";
break;
case 4:
fout << " Senior\n";
break;
default:
cout << " Invalid Code\n";
break;
}
fin >> score;
while (score != -1)
{
judgeNumber ++;
fout << "Judge " << judgeNumber << " ";
fout << score << " ";
for (scoreType = 1; scoreType < numCategories; scoreType ++)
{
fin >> score;
fout << score << " ";
sum += score;
}
fout << "\n";
fin >> score;
}
return highScore;
}
void PrintHigh (ofstream& fout, double highScore);
{
fout << "\n\n\n";
fout << "Highest Score: ";
fout.width(5);
fout << highScore << endl;
return highScore;
} //end printhigh
}
I hope i am not asking too much, but I keep on trying to fix it and
nothing seems to work. I have been working on this for days. I hope I
am not violating the board policies. I do not wish for anyone to do
things for me, but my teacher is not that good and doesnt really help
us and I need this assignment to be perfect to maintain my grade. I
have a 100 average on my assignments and just cannot seem to get this
one.
Thanks in advance
Jeff
reads from Piano.data and outputs into report.out. I have everything
working, except for the fact that it will not repeat until the end of
file is read. It just reads one display. Also the totalScore for each
player seems to come one tenth off every time i run the program. When i
try to call the PrintHigh function it is giving me a undefined
reference. If someone could tell me where I went wrong it would be
great. In the example my teacher gave the while(fin >> pianoPlayer)
read until end of file but in mine wont. Anyways here is an example of
piano.data. this is two players there are 16
6010 1
7.0 8.5 7.0 8.5
7.0 7.5 8.0 7.5
7.5 8.0 7.5 8.0
-1
6012 1
7.5 7.0 9.5 9.0
7.0 6.0 10.0 10.0
7.5 7.5 10.0 9.5
-1
Here is what report.out looks like
Federation of Music Teachers
Mardi Gras Piano Invitational Competition
Baton Rouge, Louisiana
Piano Player: 6010
Level: Primary
Type 1 Type 2 Type 3 Type 4 Overall
Judge 1 7.0 8.5 7.0 8.5 31.0
Judge 2 7.0 7.5 8.0 7.5 23.0
Judge 3 7.5 8.0 7.5 8.0 23.5
Total: 77.3
Here is my code:
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
void SetFormat (ofstream& fout);
void Header (ofstream& fout);
double Process (ifstream& fin, ofstream& fout);
void PrintHigh (ofstream& fout, double highScore);
int main()
{
ifstream fin;
ofstream fout;
double highScore;
fin.open("Piano.data");
if (fin.fail())
{
cout << "ERROR: Input File\n";
exit(1);
}
fout.open("Report.out");
if (fout.fail())
{
cout << "ERROR: Output File\n";
exit(1);
}
SetFormat(fout);
Header(fout);
highScore = Process(fin, fout);
PrintHigh (fout, highScore);
fin.close();
fout.close();
return 0;
}
void SetFormat(ofstream& fout)
{
fout.setf(ios::fixed);
fout.setf(ios:: showpoint);
fout.precision(1);
return;
} // end SetFormat
void Header(ofstream& fout)
{
fout << " \n\n Federation of Music Teachers\n";
fout << " Mardi Gras Piano Invitational Competition\n";
fout << " Baton Rouge, Louisiana\n";
return;
} // end header
double Process(ifstream& fin, ofstream& fout)
{
int numCategories;
int pianoPlayer;
int level;
int judgeNumber;
double scoreType_1, scoreType_2, scoreType_3, scoreType_4;
double highScore = -999999.99;
double score;
double totalScore;
int scoreType;
double sum;
char next;
fin >> numCategories;
while (fin >> pianoPlayer)
{
fin >> level;
judgeNumber = 0;
fout << "Piano Player: ";
fout.width(1);
fout << pianoPlayer << "\n";
fout << "Level: ";
switch(level)
{
case 1:
fout << " Primary\n";
break;
case 2:
fout << " Intermediate\n";
break;
case 3:
fout << " Advanced Intermediate\n";
break;
case 4:
fout << " Senior\n";
break;
default:
cout << " Invalid Code\n";
break;
}
fin >> score;
while (score != -1)
{
judgeNumber ++;
fout << "Judge " << judgeNumber << " ";
fout << score << " ";
for (scoreType = 1; scoreType < numCategories; scoreType ++)
{
fin >> score;
fout << score << " ";
sum += score;
}
fout << "\n";
fin >> score;
}
return highScore;
}
void PrintHigh (ofstream& fout, double highScore);
{
fout << "\n\n\n";
fout << "Highest Score: ";
fout.width(5);
fout << highScore << endl;
return highScore;
} //end printhigh
}
I hope i am not asking too much, but I keep on trying to fix it and
nothing seems to work. I have been working on this for days. I hope I
am not violating the board policies. I do not wish for anyone to do
things for me, but my teacher is not that good and doesnt really help
us and I need this assignment to be perfect to maintain my grade. I
have a 100 average on my assignments and just cannot seem to get this
one.
Thanks in advance
Jeff