-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#140 weight_conversion
77 lines (63 loc) · 1.46 KB
/
#140 weight_conversion
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
/*
Little Mac is an interplanetary space boxer, who is trying to win
championship belts for various weight categories on other planets
within the solar system.
Write a space.cpp program that helps him keep track of his
target weight by:
- It should ask him what his earth weight is.
- Ask him to enter a number for the planet he wants to fight on.
- It should then compute his weight on the destination planet.
# Planet Relative Gravity
1 Mercury 0.38
2 Venus 0.91
3 Mars 0.38
4 Jupiter 2.34
5 Saturn 1.06
6 Uranus 0.92
7 Neptune 1.19
*/
#include <iostream>
using namespace std;
int main()
{
double EarthWei = 0;
cout << "Enter your Earth weight: ";
cin >> EarthWei;
int choice = 0;
cout << "Choose the planet you want to fight on by entering its number from the following:\n";
cout << "1 Mercury\n";
cout << "2 Venus\n";
cout << "3 Mars\n";
cout << "4 Jupiter\n";
cout << "5 Saturn\n";
cout << "6 Uranus\n";
cout << "7 Neptune\n";
cin >> choice;
switch (choice)
{
case 1: //do NOT use '1' as it is for char datatype
cout << EarthWei * 0.38;
break;
case 2:
cout << EarthWei * 0.91;
break;
case 3:
cout << EarthWei * 0.38;
break;
case 4:
cout << EarthWei * 2.34;
break;
case 5:
cout << EarthWei * 1.06;
break;
case 6:
cout << EarthWei * 0.92;
break;
case 7:
cout << EarthWei * 1.19;
break;
default:
cout << "Invalid choice!";
//no need for break; as long as default is the last statement
}
}