-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMIAVG.cpp
60 lines (54 loc) · 1.36 KB
/
BMIAVG.cpp
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
#include<iostream>
#include <math.h>
// Benedikt M. Scheving-Thorsteinsson
// FSF GLPv3 Licence 2015-01-22.
// Please follow the GPL properly and link to my name if you use this. I'd be very thankful.
using namespace std;
void bmi(double& bmianswer) {
double height, weight;
cout << "Hvað ertu hár í metrum? (notaðu punkt í stað kommu)" << endl;
cin >> height;
cout << "Hvað ertu þungur í kg?" << endl;
cin >> weight;
bmianswer = weight / (height * height);
}
void average(double& avganswer) {
cout << "Hvað viltu margar tölur?" << endl;
int numberofnumbers;
cin >> numberofnumbers;
double numbertotal, number;
for (int i = 0; i < numberofnumbers; i++) {
cin >> number;
numbertotal += number;
}
avganswer = numbertotal / numberofnumbers;
}
int main() {
int whatyouwant;
bool nofunallowed = true;
while (nofunallowed) {
cout << "What would you like to do?" << endl;
cout << "1: BMI. 2: Average. 3: Exit this mofo." << endl;
cin >> whatyouwant;
switch (whatyouwant)
{
case 1:
double bmianswer;
bmi (bmianswer);
cout << "Your BMI is: " << bmianswer << endl;
break;
case 2:
double avganswer;
average (avganswer);
cout << "Your average is: " << avganswer << endl;
break;
case 3:
nofunallowed = 0;
break;
}
if (nofunallowed == 0) {
cout << "You have chosen to quit." << endl;
}
}
return 0;
}