Hi I was given an assignment to create a system that allows a user to:
1. Enter 10 Game Titles
2. Enter Graphics Score rating for each game title (1-5)
3. Enter Replay Value Score rating for each game title (1-5)
4. Find the highest graphic score
5. Find the highest replay value score
6. Find the highest combined score.
7. Exit
using a string arrays for game titles, and int arrays for graphic & replay scores.
I've done Steps 1-3 already. But I am now having trouble with how to find the highest graphic score while displaying the name of the game with the highest graphic score. Also if multiple games have the same graphic score it must choose the last highest score in the array.
This is what I have so far but the " highestGraphicScore" on displays the highest number not the game title with the highest score. Please help!
Code:#include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { //String Array For Game Title const int SIZE = 5; // Constant for array size string gameName[SIZE]; for (int index = 0; index < SIZE; index++) { cout << "Enter Game " << index + 1 << ": "; cin >> gameName[index]; } cout << "The games you entered are: " << endl; for (int index = 0; index < SIZE; index++) { cout << "Game " << index + 1 << ": " << gameName[index] << endl; } //Int Array for Graphic Scores of ( 1-5) int graphicScore[SIZE]; for (int index = 0; index < SIZE; index++) { cout << "Enter A Graphics Score (Between 1 and 5) for: " << gameName[index] << endl; cin >> graphicScore[index]; } cout << "The Graphics scores you entered for each game are: \n" << endl; for (int index = 0; index < SIZE; index++) { cout << "Game " << index + 1 << ": " << graphicScore[index] << endl; } //Int Array for Replay Score of (1-5) int replayScore[SIZE]; for (int index = 0; index < SIZE; index++) { cout << "Enter A Replay Score (Between 1 and 5) for: " << gameName[index] << endl; cin >> replayScore[index]; } cout << "The Replay scores you entered for each game are: \n" << endl; for (int index = 0; index < SIZE; index++) { cout << "Game " << index + 1 << ": " << replayScore[index] << endl; } //Find the Highest Graphic Score int highestGraphicScore = 0; for (int index = 0; index < SIZE; index++) { if (graphicScore[index] > highestGraphicScore) highestGraphicScore = graphicScore[index]; cout << " The Highest Graphic Score is: " << highestGraphicScore << endl; } //Find the Highest Replay Score int highestReplayScore = 0; for (int index = 0; index < SIZE; index++) { if (replayScore[index] > highestReplayScore) highestReplayScore = replayScore[index]; } cout << "The Highest Replay Score is: " << highestReplayScore << endl; return 0; }