-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcingolf.cpp
More file actions
34 lines (30 loc) · 805 Bytes
/
cingolf.cpp
File metadata and controls
34 lines (30 loc) · 805 Bytes
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
#include <iostream>
const int Max = 5;
using namespace std;
int main(int argc, char *argv[])
{
int golf[Max];
std::cout << "Please enter your golf scores." << std::endl;
std::cout << "You must enter " << Max << " rounds." << std::endl;
int i;
for(i=0; i<Max; i++)
{
std::cout << "round #" << i+1 << std::endl;
while(!(cin>>golf[i]))
{
cin.clear();
while(cin.get() != '\n')
{
continue;
}
std::cout << "Please enter a number: " << std::endl;
}
}
double total = 0.0;
for(i=0; i<Max; i++)
{
total += golf[i];
}
std::cout << total/Max << " = average score " << Max << " rounds"<< std::endl;
return 0;
}