-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathexp5_1.cpp
37 lines (33 loc) · 874 Bytes
/
exp5_1.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
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
#define EPS = 1e-1
//ʵÑé5.1
//Éí¸ßÔ¤²â
int main(){
char sex,sports,diet;
float faHeight,moHeight,height;
cout << "F-female M-male" << endl;
cin >> sex;
cout << "please input the parents' height" <<endl;
cin >> faHeight >> moHeight ;
cout << "Do you like playing sports?" << endl;
cin >> sports;
cout << "Do you have a healthy diet?" << endl;
cin >> diet;
switch(sex){
case 'F':
height = (faHeight * 0.923 + moHeight) / 2;
break;
case 'M':
height = (faHeight + moHeight) * 0.54;
}
if (sports == 'y' || sports == 'Y')
height *= 1.02;
if (diet == 'y' || diet == 'Y')
height *= 1.015;
cout << "the height is predicted to be " << height << " cm" << endl;
return 0;
}