I have been fiddling with these damn loops for hours. I am new to c++ but not too programming. My teacher is absolutely worthless. she refuses to help me and explains things very poorly. I have a 100 % on the assignments in the class and do not wish to drop because of this one. I read the sticky about students and believe me I am not one of them . I have been up for like 12 hours messing with this. Here is the problem: I am supposed to read numbers out of a file piano.data and put the results into report.out. The piano file is structured like this

4 // number of categories
6010 // student number 1 // level of proficiency
7.0 8.5 7.0 8.5 //scores judge 1
7.0 7.5 8.0 7.5 //scores judge 2
7.5 8.0 7.5 8.0 //scores judge 3
-1 //no more judges
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

The problem I have is that I can put the header in, read the student number, display it and use a switch operater to display profieciency. I then have a counter control set up to spit out which judge and then the scores are listed after. Problem being is that it will only display the first list of scores or if i fiddle with it it will just display shit loads of judges with correct scores but eventually the numbers get garbled. It will never
repeat the student part or the profiency. I believe a sentinal controls one of loops and she wants a for controlled counter statement. then the outer loop searches for end of file i think. I dont know it may be four loops. I am submitting the one that works the best because the ones with more loops spit out all kinds of wierd stuff. here is my 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);
	
	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 = 0;
	double scoreType_1, scoreType_2, scoreType_3, scoreType_4;
	double highScore = -999999.99;
	double score;
	double totalScore;
	
	fin >> numCategories;
	while (! fin.eof())
	{
		
		fin >> pianoPlayer;
		fin >> level;
		fout << "Piano Player: ";
		fout.width(1);
		fout << pianoPlayer << "\n";
		fout << "Level: " << level << "\n\n";
		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;
		}	
		
		while (scoreType_1 != -1)
		{
			judgeNumber ++;
			fin >> scoreType_1 >> scoreType_2 >> scoreType_3 >> scoreType_4;
			fout << "Judge ";
			
			fout << judgeNumber << "  ";
			score = scoreType_1 + scoreType_2 + scoreType_3 + scoreType_4;
			fout.width(6);
			fout << "Type 1  Type 2  Type 3  Type 4  Score\n";
			fout << scoreType_1 << "   " << scoreType_2 << "   " <<scoreType_3 
			     << "   " << scoreType_4 << score;
			totalScore += score;
			fout << "\n----------------------------------------\n";
			fout << "Total: ";
			fout << totalScore;
			
		}
void PrintHigh (ofstream& fout, double highScore);
	{
		fout << "\n\n\n";
		fout << "Highest Score:  ";
		fout.width(5);
		fout << highScore << endl;
		return highScore;
	} //end printhigh	
	}
}

If someone could just point me in the right direction with how to go in and out of the loops I could do the rest.

Recommended Answers

All 15 Replies

><snip angsty whining> I am supposed to read numbers out
>of a file piano.data and put the results into report.out.
How are the results to be formatted? Give us an example run of the program.

>The piano file is structured like this
Exactly like that? Or are you adding your own commentary? The difference is in how you parse the data, and that's a pretty big difference.

It's not a good idea to use return value of eof() as a loop conditional as it commonly causes process body of loop one too many times. You would be better checking return value of attempting to read in the piano players number as the conditional. When the stream gets to the end of the file and trys to read in EOF it will go into failed state and return false, stopping the loop appropriately, rather than inappropriately processing the body of the loop that last time. Of course, if you want to reuse the stream again you will need to clear the stream somehow, but you should learn how to do that anyway.

In your version you don't use the value of numCategories at all once it is read in. Rather than reading the results of eachof the score types into discreet variables you could use numCategories to terminate a for loop used to read in the score types from each judge. If you want to store the test scores to print them out again later or whatever you could store them in a container rather than discreet named variables.

I suspect you will want to reset the number of the judge for each new piano player, otherwise the judge number will keep on rising. In this scenario the outer loop could control which piano player is being judged a middle loop controls which judge is judging and an inner loop controls which score value is being read in.

read in numCategories
while(succeffully reading in a pianoPlayerNumber)
   read in proficiency level
   set judge number to 0
   while(no further judges scores to tally)
      increase judge number
      for each score type
         add to score for this judge
         store value for later use if desired
      add score for this judge to total score for this piano player
    compare this piano players score versus the best so far
       adjust the best score if need be
determine why input failed
   if eof()
     end of file found, expected result
   else
     error found in file, unexpected result
clear input stream for reuse

that sounds good. how do I determine if there are no furthur duges to tally. check for the -1? and how do i cleaer the input stream? and how do i determine if input failed?

>>how do I determine if there are no furthur duges to tally. check for the -1
sounds good

>>and how do i cleaer the input stream?
inputStreamName.clear();

>>how do i determine if input failed
You will know the input failed becaue the external loop will stop working, unless it goes into an endless loop scenario. In turn, the external while loop will cease when the conditional evaluates to false. In this case the input stream will evaluate to false when it fails to read in a piano players number. For example, the input stream will fail when it tries to read in EOF, which is the end of file marker, and which is what you want to have happen because it means you successfully read the whole file, OR it will fail if the file is corrupted somehow and the expected input types aren't in the expected places in the file--for example you try reading a string into an int or whatever. So, when the external while loop stops working it stopped because the input stream failed. If it stopped because you found EOF, that's good. You test for that possibiliy by looking at the return value of eof() after the input stopped. Otherwise, the input stream failed for a reason other than finding EOF and that's bad because it means somethings screwed up somewhere and you'll have to track it down.

thanks. I think i almost have it. I have a few more bus to work outbut I should be able to get much further. I will repost the updated code. I appreciate your help.

D'oh, I misread the thread - post contents deleted.

Ok. I have made the file be formatted correctly. I also have added a total score for all the judges overall score. Problem is it comes up a tenth of a point wrong or so every time I run it. Also I cannot seem to make the pianoPlayer loop. It only lists one student. When I try and extract the
void PrintHigh function it gives me errors about return values. I cannot have the double Process function return highScore and the void PrintHigh have return; Here is the code. Without the call to the PrintHigh function. can anyone tell me where I am going wrong. I have not put in the if statement to check to see if the overall high score is the current player as the high score funtion does not work. Can anyone explain the if and else statements that the guy helping me before put in more detail.

#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);
	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\n";
	return;
}  // end header

double Process(ifstream& fin, ofstream& fout)
{
	int numCategories;
	int pianoPlayer;
	int level;
	int judgeNumber;
	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;
		}
		fout << "\n";
		fout.width(15);
		fout << "Type 1" << " Type 2" << " Type 3" << " Type 4" << " Overall\n";
		fin >> score;
		sum += score;	
		while (score != -1)
		{
			
			judgeNumber ++;
			fout << "Judge " << judgeNumber << "  ";
			fout << "   " << score;
			for (scoreType = 1; scoreType < numCategories; scoreType ++)
			{
				fin >> score;
				fout.width(7);
				fout << score;
				sum += score;
			}
			fout << "    " << sum;
			totalScore += sum;
			sum = 0;
			fout << "\n";
			
			fin >> score;
			
		}
		fout << "Total: " << totalScore << "\n";
		totalScore = 0;
	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'm surprised your code as posted compiles because you seem to be missing (at least) a closing bracket in Process().

I think the problem you describe is because you have a return statement at the end of the loop for each piano player rather than at the end of evaluating all piano players, which means only one piano players scores will be read from file.

Below is a skeletized set of loops and how to incorporate looking for the highestScore as well as checking why the outer loop stopped.

double Process(ifstream& fin, ofstream& fout)
{
  while (fin >> pianoPlayer)
  {
     while (score != -1)
     {
        for (scoreType = 1; scoreType < numCategories; scoreType ++)
        {
        }			
     }
     if(totalScore > highScore)
        highScore = totalScore;
  }
  if(fin.eof())
    cout << "file reading completed correctly. Congratulations!" << endl;
  else
    cout << "error in reading file.  sorry" << endl;

  fin.clear();	
  return highScore;
}

lerner you are the shit. It all had to do with the brackets. I cannot believe I screwed with it for so long and did not notice that. It is all working great now. I fixed the formatting and added the totaler and made a total for each judge. The only problem I have is on the first student the total score is always .2 off. I cannot figure out why. Can you help me just one more time? Also is there anyway to break this function up into multiple functions because she says they souldnt be as long as mine is.

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;
	double score;
	double totalScore;
	int scoreType;
	double sum;
	char next;
	fin >> numCategories;
	while (fin >> pianoPlayer)
	{
		fin >> level;
		judgeNumber = 0;
		fout << "\nPiano 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;
		sum += score;
		fout << "\n            Type_1      Type_2      Type_3      Type_4      Score\n";
		while (score != -1)
		{
			judgeNumber ++;
			fout << "Judge " << judgeNumber << "     ";
			fout.width(6);
			fout << score;
			for (scoreType = 1; scoreType < numCategories; scoreType ++)
			{
				fin >> score;
				fout.width(12);
				fout << score;
				sum += score;
			}
			fout.width(11);
			fout << sum;
			totalScore += sum;
			fout << "\n";
			fin >> score;
			sum = 0;
		}
		fout << "\nTotal:" << totalScore << "\n";
		if(totalScore > highScore)
        		highScore = totalScore;
		totalScore = 0;
	}
	return highScore;
}

The only thing I can think of is to initialize sum and totalScore to 0 at time of declaration. I don't see that you initialize sum or totalScore before the are used the first time. You do reset them to 0 after each use, but I don't see it before the first use.

As to breaking it up into functions, I suppose you could do something like

ProcessFile()
{
   ProcesPlayers()
   {
       DisplayLevel();
       ProcessPlayerScores()
          TallyJudgesScores();
  }
}

Where basically each loop or switch is isolated in its own function. I don't care for that style as is seems to cut up the code making it more difficult for me to follow, but it may suit your instructor better and is does satisfy the general rule that a function should do one thing only making it easier to maintain.

Lerner you are the shit. Anyways i redid with the multiple functions. For some reason for the functions within ProcessFile function i have to put a smicolon after it. Is that normal. My teacher never did one anywhere near as compicated as this. there was always only one function at a time. Anyways Here is my complete file. could you look at my documentation for the functions and see if i am doing that right? Thanks for all your help. you have saved my ass. It is funny that basically my whole problem this entire time has been that damn return statement and one }. anyways thanks again.

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

void SetFormat	(ofstream& fout); // function to set format
void Header	(ofstream& fout); // function to print header
void PrintHigh  (ofstream& fout, double highScore); // function that prints high score
double ProcessFile (ifstream& fin, ofstream& fout); // function that processes Piano.data until eof
double ProcessPlayers (ifstream& fin, ofstream& fout); // function that processes each player
double DisplayLevel (ifstream& fin, ofstream& fout); // function that determines level
double ProcessPlayerScores(ifstream& fin, ofstream& fout); //function that processes players scores
double TallyJudgesScores(ifstream& fin, ofstream& fout); //function that totals scores of each judge

int main()
{
	ifstream fin; // sets ifstream to fin
	ofstream fout; // sets ofstream to fout
	double highScore; //sets up variable highScore
	
	// opens Piano.data and exits program if error is encountered
	fin.open("Piano.data");
	if (fin.fail())
	{
		cout << "ERROR: Input File\n";
		exit(1);
	}
	// opens Report.out and exits program if error is encountered
	fout.open("Report.out");
	if (fout.fail())
	{
		cout << "ERROR: Output File\n";
		exit(1);
	}
	
	SetFormat(fout); 
	Header(fout); 
	highScore = ProcessFile(fin, fout);  
	PrintHigh  (fout, highScore);
	fin.close();
	fout.close();
	return 0;
}

/************************************************************************************************/
/* Function Name: SetFormat									*/
/* Function Purpose: Setup formatting of fout							*/
/* Input Parameters: none									*/
/* Return value: none										*/
/************************************************************************************************/
void SetFormat(ofstream& fout)
{
	fout.setf(ios::fixed);
	fout.setf(ios::showpoint);
	fout.precision(1);
	return;
}  // end SetFormat

/************************************************************************************************/
/* Function Name: Header									*/
/* Function Purpose: Output the header of file							*/
/* Input Parameters: none									*/
/* Return value: none										*/
/************************************************************************************************/
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

/************************************************************************************************/
/* Function Name: ProcessFile									*/
/* Function Purpose: process file 								*/
/* Input Parameters: 1.  the number of categories for each judge				*/
/* Return value: none										*/
/************************************************************************************************/
double ProcessFile(ifstream& fin, ofstream& fout)
{
	int numCategories; //number of categories in competition
	double highScore = 0; //high score of competition
	// recieve number of categories from Piano.data
	fin >> numCategories;
	/************************************************************************************************/
	/* Function Name: ProcessPlayers								*/
	/* Function Purpose: process PianoPlayers until eof reached					*/
	/* Input Parameters: 1. pianoPlayer: which piano player is being judged				*/
	/* Return value: highScore									*/
	/************************************************************************************************/
	double ProcessPlayers(ifstream& fin, ofstream& fout);
	{
		int pianoPlayer; //piano player number
		while (fin >> pianoPlayer)
		{
			// print piano player
			fout << "\nPiano Player: ";
			fout.width(1);
			fout << pianoPlayer << "\n";
			/************************************************************************/
			/* Function Name: DisplayLevel						*/
			/* Function Purpose: determine what level player is and output the level*/
			/*		     ftom numerical to actually name ex: 1 is primary   */
			/* Input Parameters: level						*/
			/* Return value: none							*/
			/************************************************************************/
			double DisplayLevel(ifstream& fin, ofstream& fout);
			{
				// get level and output
				int level; // level of experience
				fin >> level;
				fout << "Level: ";
				// convert number to text explanation of 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;
				} //end switch statement to print level name
			}  // end DisplayLevel
			/************************************************************************/
			/* Function Name: ProcessPlayerScores					*/
			/* Function Purpose:  To read in players initial score and setup loops  */
			/*		      to tally them and check to see if highest		*/
			/* Input Parameters: 	1. score : the score for a judge for one cate	*/			
			/* Return value: none							*/
			/************************************************************************/
			double ProcessPlayerScores(ifstream& fin, ofstream& fout);
			{
				double score = 0; // score for each player
				double sum = 0; // sum of scores for each judge
				double totalScore = 0; // total score of player
				int judgeNumber = 0, scoreType; // judge counter
				
				fin >> score;
				sum += score;
				fout << "\n            Type_1      Type_2      Type_3      Type_4      Score\n";
				/************************************************************************/
				/* Function Name: TallyJudgesScores					*/
				/* Function Purpose: Read in the scores and tally them for each judge as*/
				/*		     well as for total for player. Also contains counter*/
				/*		     for judges.                                        */
				/* Input Parameters: 	1. score : the score for a judge for one cate	*/		
				/* Return value: none							*/
				/************************************************************************/
				double TallyJudgesScore (ifstream& fin, ofstream&fout);
				{
					while (score != -1)
					{
						judgeNumber ++;
						//format and print judge number and scores for that judge
						fout << "Judge " << judgeNumber << "     ";
						fout.width(6);
						fout << score;
						for (scoreType = 1; scoreType < numCategories; scoreType ++)
						{
							fin >> score;
							fout.width(12);
							fout << score;
							sum += score;
						} //end rep for each scores for each judge
						//format and pring total score for judge
						fout.width(11);
						fout << sum;
						totalScore += sum;
						fout << "\n";
						fin >> score;
						sum = 0;
					} //end rep for reading scores
				}  //end TallyJudgesScore
				//print total score
				fout << "\nTotal:" << totalScore << "\n";
				//find high score
				if(totalScore > highScore)
					highScore = totalScore;
				totalScore = 0;	
			} //end ProcessPlayersScores
			
		} //end outer loop that determines if end of file
	return highScore;  
	} //end ProcessPlayers
}  // end ProcessFile
/************************************************************************/
/* Function Name: DisplayLevel						*/
/* Function Purpose: To print the highest score of all players		*/
/* Input Parameters: highScore:  the highest score of all players	*/
/* Return value: none							*/
/************************************************************************/	
void PrintHigh (ofstream& fout, double highScore)
{
	fout << "\n\n\n";
	fout << "Highest Score:  ";
	fout.width(5);
	fout << highScore << endl;
	return;
} //end printhigh

Well, my last post seems to have thrown you off kilter some. Don't forget you should have some information from your notes and your book on how to do this and don't rely on me for 100% accuracy.

In your current post you shouldn't declare and define one function within another, which I admit may have looked like what I was trying to do in my last post. Instead it should be more like this skeletal version:

#include <iostream>
using namespace std;

//declare ProcessFile() here
//declare ProcessPlayers() here
//declare DisplayLevel() here
//declare ProcessPlayerScores() here
//declare TallyJudgesScores() here

int main()
{
   //declare streams to pass among the functions and other stuff here
   
  //call ProcessFile() here
  //call PrintHigh() here
  
  //close streams here
}

//define ProcessFile() here
  //within ProcessFile() call ProcessPlayers()

//define ProcessPlayers() here
  //within ProcessPlayers()  call DisplayLevels() here
  //within ProcessPlayers() call ProcessPlayerScores() here

//define DisplayLevels() here

//define ProcessPlayerScores() here
   //within ProcessPlayerScores() call TallyJudgesScores() here
   
//define TallyJudgesScores() here

In general you can call a function before it is defined as long as it has been declared already.

my teacher never gave us examples of how to break up functions like that.
She only gave us examples where we would need to call one process function. she always does this. we are supposed to learn to do things while doing our assignments. My book goes into it some. I tried to do it the correct way, but I am confused about what values to return on each function. The program runs and just prints the header and the highscore as 0. here is the code.

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

void SetFormat	(ofstream& fout);
void Header	(ofstream& fout);
void PrintHigh  (ofstream& fout, double highScore);
double ProcessFile (ifstream& fin, ofstream& fout);
void ProcessPlayers (ifstream& fin, ofstream& fout);
void DisplayLevel (ifstream& fin, ofstream& fout);
void ProcessPlayerScores(ifstream& fin, ofstream& fout);
void TallyJudgesScores(ifstream& fin, ofstream& fout);
void HighScore (ifstream& fin, ofstream& fout);
double highScore, totalScore, sum, score;
int scoreType, numCategories, judgeNumber;

int main()
{
	ifstream fin;
	ofstream fout;
	
	
	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 = ProcessFile(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 ProcessFile(ifstream& fin, ofstream& fout)
{
	int numCategories;
	double highScore = 0;
	fin >> numCategories;
	return highScore;
}
void ProcessPlayers(ifstream& fin, ofstream& fout)
{
	int pianoPlayer;
	while (fin >> pianoPlayer)
	{
			fout << "\nPiano Player: ";
			fout.width(1);
			fout << pianoPlayer << "\n";
			DisplayLevel (fin, fout);
	}
	return;
}
void DisplayLevel(ifstream& fin, ofstream& fout)
{
	int level;
	fin >> level;
	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;
	}
	ProcessPlayerScores (fin, fout);
	return;
}
void ProcessPlayerScores(ifstream& fin, ofstream& fout)
{
	double score = 0;
	double sum = 0;
	double totalScore = 0;
	int judgeNumber = 0, scoreType;		
	fin >> score;
	sum += score;
	fout << "\n            Type_1      Type_2      Type_3      Type_4      Score\n";
	TallyJudgesScores (fin, fout);
	return;
}
void TallyJudgesScores (ifstream& fin, ofstream& fout)
{
	while (score != -1)
	{
		judgeNumber ++;
		fout << "Judge " << judgeNumber << "     ";
		fout.width(6);
		fout << score;
		for (scoreType = 1; scoreType < numCategories; scoreType ++)
		{
			fin >> score;
			fout.width(12);
			fout << score;
			sum += score;
		}
					
		fout.width(11);
		fout << sum;
		totalScore += sum;
		fout << "\n";
		fin >> score;
		sum = 0;
	}
	fout << "\nTotal:" << totalScore << "\n";
	HighScore (fin, fout);
	return;
}
void HighScore (ifstream& fin, ofstream& fout)
{
	if(totalScore > highScore)
			highScore = totalScore;
		totalScore = 0;
	return;	
}
		
	
	
void PrintHigh (ofstream& fout, double highScore)
{
	fout << "\n\n\n";
	fout << "Highest Score:  ";
	fout.width(5);
	fout << highScore << endl;
	return;
} //end printhigh

I redid the whole program and it ended up working. It is always these little bullshit errors that mess me up. I wasnt calling the functions right and at the right time and was returning incorrect values. Thanks for all your helped you help maintain my 100 average on assignments

Jeff

Congratulations!

You have no idea how much time I've spent tracking down a missed bracket or a semi colon that should have been a comma, etc. I've learned to live it. I suspect you will too if you like the feeling you get when you eventually reach your goal.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.