Hello, first time posting here. I have to make a program using arrays to get the highest score out of 10 games and the name of the game associated with the high score. I'm having trouble getting the name of the game to print out along with the high score, any pointers on how to get it working properly? Here's the particular area that I'm having problems with, thanks in advance. (I tried using the code format on the bottom but it doesn't seem to be working.)
void getHighestGraphics(string gameTitle[], int graphicScore[]) { // Function used to get highest graphic score.
int graphicMax = graphicScore[0];
int x = 0;
for (x = 0; x < 10; x++)
{
if (graphicScore[x] > graphicMax) {
graphicMax = graphicScore[x];
}
}
cout << "The highest rated graphics game is " << gameTitle[graphicMax] << " with a score of " << graphicMax << endl;
}
Thanks so much! I was breaking my head over that. I have one more question if you don't mind: The last part of my assignment I need to get two combined scores, store them in an array, and cout the game title with the highest combined score. I'm getting an error when trying to pass 3 parameters to the function. Is this even allowed? I'll post the code I tried.
1 2 3 4 5 6 7 8 9 10 11 12
void getHighestCombined(string gameTitle[],int graphicScore[], int replayValue[]) { // Function used to get highest combined score.
int c = 0;
int indexHighestCombined = graphicScore[0] + replayValue[0];
for (c = 0; c < 10; c++) {
if (graphicScore[c] + replayValue[c] > graphicScore[indexHighestCombined] + replayValue[indexHighestCombined]) {
indexHighestCombined = c;
}
}
cout << "The highest rated combined score game is " <<gameTitle[indexHighestCombined] << " with a score of" << graphicScore[indexHighestCombined] + replayValue[indexHighestCombined] << endl;
}
The error that I'm getting is:
'getHighestCombined': no overloaded function takes 2 arguments.
When I click on the error is comes to this line of code:
1 2 3
case 6:
getHighestCombined(gameTitle,graphicScore,replayValue);
break;