Loop Error

I posted this a little bit ago and made some changes but am stuck on two errors now that i cant figure out.

Error 2 error C1075: end of file found before the left brace '{' at 'c:\users\jocko\documents\visual studio 2012\projects\consoleapplication44\consoleapplication44\source.cpp(31)' was matched c:\users\jocko\documents\visual studio 2012\projects\consoleapplication44\consoleapplication44\source.cpp 91 1 ConsoleApplication44

Error 1 error C2146: syntax error : missing ';' before identifier 'averageScore' c:\users\jocko\documents\visual studio 2012\projects\consoleapplication44\consoleapplication44\source.cpp 85 1 ConsoleApplication44


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  // ---------------------------------------------------------------
// Programming Assignment:	LAB 03
// Developer:			Jocko Davis
// Date Written:		03/26/2014
// Purpose:				Dive Score Calculator
// ---------------------------------------------------------------

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	//initialize variables
	string name = "";
	string city = "";
	char anotherDiver = 'y';
	int judgesNumber = 1;
	int diverCounter = 1;
	double highScore = 10;
	double lowScore = 0;
	double overallScore = 0;
	double totalOverallScore = 0;
	double totalScore = 0;
	double score = 0;
	double difficultyLevel = 0;
	double averageScore = 0;

	while ( anotherDiver == 'y' || anotherDiver == 'Y')
	{
	cout << "Event: Diving Competition" << endl;
	cout << fixed << setprecision (2);

	// get name and city
	cout << "Enter divers name: ";
	getline(cin, name);
	cout << "Enter divers city: ";
	getline(cin, city);
	
	for (int judgesNumber = 1; judgesNumber < 6; judgesNumber++)
	{
		cout << "Enter the judges score " << judgesNumber << ": ";
		cin >> score;
	}
		// validate score range
		while(score < 0 || score > 10)
		{
			cout << "Your score is not in range." << endl;
			cout << "Enter judge # " << judgesNumber << ": ";
			cin >> score;
		}
		if (score > lowScore)
		{
			highScore = score;
		}
		// check if score is lowest
		if (score < highScore)
			{
				highScore = score;
			}
		totalOverallScore += score;
	}

		// validate difficulty
		cout << "Input the Divers Difficulty level: ";
		cin >> difficultyLevel;
			
			if (difficultyLevel < 1.00 || difficultyLevel > 1.67)
			{
				cout << "Your difficulty score not in range. ";
				cout << " Enter score between 1 and 1.67: ";
				cin >> difficultyLevel;
			}

		totalScore = (totalScore - highScore - lowScore)/3;
		overallScore = totalScore * difficultyLevel;
		

			cout << " Diver: " << name << endl;
			cout << " City: " << city << endl;
			cout << " Divers total score: " << overallScore << endl;
			cout << " Press Y for another diver or N to end diver inputs" << endl;
			cin >> anotherDiver;
			cin.ignore();
		
		cout << "The number of divers: " << diverCounter << endl;
		cout << "The average score: " << totalOverallScore / diverCounter << endl;
		return 0;
}
cin >> anotherDiver; is outside the closing brace for the while loop you're controlling by that value.


Edit:

This keeps overwriting score with the value of the next judge before you get a chance to run it through the validation.
1
2
3
4
5
		for (int judgesNumber = 1; judgesNumber < 6; judgesNumber++)
		{
			cout << "Enter the judges score " << judgesNumber << ": ";
			cin >> score;
		}
Last edited on
just a few more things if you could point me in the right direction i would appreciate it im not getting a error for incorrect judge score and when i get to the end of the program its not display the number of divers just a 1
I don't see that you're incrementing the divercounter anywhere, so it's staying with its initial value of 1.
Topic archived. No new replies allowed.