Skip to content

Commit bfd8ec8

Browse files
adeed a relative gravity calculator
1 parent 9082835 commit bfd8ec8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.DS_Store

6 KB
Binary file not shown.
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
5+
int main() {
6+
7+
double planet_Weight;
8+
double earth_Weight;
9+
double calc = earth_Weight * planet_Weight;
10+
11+
cout << "What is your weight on earth? LBS : ";
12+
cin.clear();//you need to clear the flags before input
13+
getline (cin, earth_Weight);
14+
15+
16+
std::cout << "Choose a relative gravity for the planet in which you want to know your weight on : Planet Relative Gravity Earth = 1 , Venus = 0.78 , Mars = 0.39 , Jupiter = 2.65 , Saturn = 1.17 , Uranus = 1.05 , Neptune = 1.23: \n";
17+
cin.clear();//you need to clear the flags before input
18+
getline (cin, planet_Weight);
19+
20+
21+
if (planet_Weight == 1) {
22+
cout << "Your weight on Earth is... " << calc;
23+
} else if (planet_Weight == 0.39) {
24+
cout << "Your weight on Mars is... " << calc;
25+
} else if (planet_Weight == 0.78) {
26+
cout << "Your weight on Venus is... " << calc;
27+
} else if (planet_Weight == 2.65) {
28+
cout << "Your weight on Jupiter is... " << calc;
29+
} else if (planet_Weight == 1.17) {
30+
cout << "Your weight on Saturn is... " << calc;
31+
} else if (planet_Weight == 1.05) {
32+
cout << "Your weight on Uranus is... " << calc;
33+
} else if (planet_Weight == 1.23) {
34+
cout << "Your weight on Neptune is... " << calc;
35+
} else {
36+
37+
cout << "Your weight on this planet is Unknown... ";
38+
39+
40+
}
41+
42+
}

0 commit comments

Comments
 (0)