OK, the first thing is to use code tags, they make it much easier to read your code. Use the <> buttton on the right under format.
1 2 3 4
|
// Write report heading
cout << "\tReport to the media\n";
cout << "Event: Diving Competition\n\n";
char choice = 'Y';
|
I would put this near the end when you have all the info. Writing the report should be a function.
1 2
|
char choice = 'Y';
while (choice == 'Y' && choice == 'y');
|
This has several probelms: First, it doesn't do anything (the code in the braces is never executed), for 2 reasons - can you figure out why? Clues are the semicolon, and the && operator.
Apart from this, if the intention was to be able to re run the program, you need to be more clear about how you are going to do this. Try using a bool variable to accomplish this.
Investigate using an array of structs. Here is an example struct.
1 2 3 4
|
struct Diver {
string Name = ""; //The divers name
string City = ""; //The divers home town
};
|
Notice how they are strings, not a char.
Now you could have an array of these, the size of which could be determined by a const unsigned short variable. This way you don't have to have this :
1 2 3 4 5 6 7 8 9 10
|
char diverName1 = 'a';
char diverName2 = 'b';
char diverName3 = 'c';
char diverName4 = 'd';
char diverName5 = 'e';
char diverCity1 = 'f';
char diverCity2 = 'g';
char diverCity3 = 'h';
char diverCity4 = 'i';
char diverCity5 = 'j';
|
The scores & difficulty could be an array inside the struct.
1 2 3 4 5 6 7 8 9 10
|
// Using a do-while loop input the 5 judge's scores
do
{
cout << "Enter the score given by judge #1: ";
cin >> scoreJudge1;
if ((scoreJudge1 < 0) || (scoreJudge1 > 10))
{cout << "Invalid score - Please reenter (Valid Range: 0 - 10)" << endl;
cout << "Enter the score given by judge #2: ";
cin >> scoreJudge2;
|
Now this needs to be in a loop - what if you had 10 judges, would you write this code 10 times? So you need nested loops, One to go through the array of divers, another to get the scores & difficulty. The main idea is to write code once, so if you find yourself writing the same code, then you probably need a loop.
With this code, if input is invalid, it jumps to the next judge with no opportunity to fix the problem.
Usually, the collection of the input and the validation of it should be inside a function.
This condition for the do loop isn't right.
} while ((scoreJudge1 < 0) || (scoreJudge1 > 10));
I try to avoid using do loops, I much prefer to use a while or for loop where ever possible.
Any way this is a start, see how you go with an array of structs.