Background counter outside loop

For homework I am tasked to write a program that tallies multiple diver scores in a loop. This part I have done and it is correct. What I need help with is a summary page (outside loop) with diver entries and average score for all divers.


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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
	int entry, count = 0;
		double sum;
		//int average;
		double overAllscore;
		double dOd;
		double a, b, c, d, e;
		double largest;
		double smallest;
		string diversname;
		string state;
		string city;
		char choice;
		
		do {
	labelbegin:
				cout << "Welcome to the NEW and Improved Diver input program!" << endl;
				cin.get();
				cout << "Enter diver's name: ";
				getline(cin, diversname);
				cout << "What city is the diver from: ";
				getline(cin, city);
				cout << "What state is the diver from: ";
				getline(cin, state);

				cout << "Enter the diver's score of, 0 through 10, in any order. " << endl << endl;

			labelA:
				cout << "Enter 1st score." << endl;

				cin >> a;
				cout << fixed << setprecision(2);
				if (a > 10)  goto labelA;
				if (a < 1)  goto labelA;

			labelB:
				cout << "Enter 2nd score." << endl;

				cin >> b;
				if (b > 10)  goto labelB;
				if (b < 1)  goto labelB;

			labelC:
				cout << "Enter 3rd score." << endl;

				cin >> c;
				if (c > 10) goto labelC;
				if (c < 1) goto labelC;

			labelD:
				cout << "Enter 4th score." << endl;

				cin >> d;
				if (d > 10) goto labelD;
				if (d < 1) goto labelD;

			labelE:
				cout << "Enter 5th score." << endl;

				cin >> e;
				if (e > 10) goto labelE;
				if (e < 1) goto labelE;

			labeldOd:
				cout << "How difficult was the diver's routine? Enter 1.00 through 1.67 " << endl;

				cin >> dOd;
				if (dOd > 1.67) goto labeldOd;
				if (dOd < 1.00) goto labeldOd;



				sum = b + c + d;

				//average = (sum / 3);

				overAllscore = ((sum / 3) * dOd);

				cout << diversname << ", from " << city << ", " << state << " score is: " << overAllscore << endl;






				if (a > b)
				{
				if (a > c)
					{{
				if (a > d)
							{{
				if (a > e)
									{
				largest = a;
									}}}}}}
				if (b > c)
				{
				if (b > d)
					{{
				if (b > e)
							{{
				if (b > a)
									{
				largest = b;
									}}}}}}
				if (c > d)
				{
				if (c > e)
					{{
				if (c > a)
							{{
				if (c > b)
									{
				largest = c;
									}}}}}}
				if (d > e)
				{
				if (d > a)
					{{
				if (d > b)
							{{
				if (d > c)
									{
				largest = d;
									}}}}}}
				if (e > d)
				{
				if (e > a)
					{{
				if (e > b)
							{{
				if (e > c)
									{
				largest = e;
									}}}}}}

				if (a < b)
				{
				if (a < c)
					{{
				if (a < d)
							{{
				if (a < d)
									{
				smallest = a;
									}}}}}}
				if (b < c)
				{
				if (b < d)
				{{
				if (b < e)
							{{
				if (b < a)
									{
				smallest = b;
									}}}}}}
				if (c < d)
				{
				if (c < e)
					{{
				if (c < a)
							{{
				if (c < b)
									{
				smallest = c;
									}}}}}}
				if (d < e)
				{
				if (d < a)
					{{
				if (d < b)
							{{
				if (d < c)
									{
				smallest = d;
									}}}}}}
				if (e < a)
				{
				if (e < b)
					{{
				if (e < c)
							{{
				if (e < d)
									{
				smallest = e;
									}}}}}}

				cout << "Do you have more diver entries to make? y/n ";
				cin >> choice;
				if (choice == 'y') goto labelbegin;
				else (choice == 'n'); // At this point, I would need 
//the  program to tally entries and average the scores based on how 
//many entries were made.
			
			
			cout << "Summary Report." << endl;  
		}while (entry >= '100', count++);
		{
			cin>> entry;
		};
		cout << "Total number of entries: " << entry; 
		return 0;
		cin.get();
	


}


This is only Week 3 of my C++ class, so I have no idea about vectors or arrays, but always willing to learn and see how it is done, instead of reading and hoping I got it right.
Last edited on
No idea without seeing your code.

BTW, your while condition is bogus. C++ does not support implied left hand side. You must full specify both conditions.
 
while (choice == 'y' || choice == 'Y');


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Suggest you set up a struct Diver on the following lines:
1
2
3
4
5
struct Diver
{
    std::string m_name;
    std::vector<double> m_scores;
};

... then in main() have a loop to enter either (a) all the scores for a given diver or (b) all the divers' scores for a given round with appropriate push_back into the m_scores datamember for each diver.
When reading in the data is complete use std::accumulate() over m_scores to sum all the scores for a diver, divide by m_scores.size() and that'd give you the average for a single diver; repeat for all divers
Topic archived. No new replies allowed.