Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Program to check weight on different planets using if-else if-else statement.
- Compile and execute using:
- g++ space.cpp
- ./a.out
- */
- #include <iostream>
- int main() {
- double weight;
- int plat;
- std::cout << "Enter your earth weight: ";
- std::cin >> weight;
- std::cout << "\nChoose the planet number that you wanna fight on: \n\n";
- std::cout << "1. Mercury\n 2. Venus\n 3. Mars\n 4. Jupiter\n 5. Saturn\n 6. Uranus\n 7. Neptune\n";
- std::cin >> plat; //remember to store input into variable!!
- if (plat == 1 ){
- weight *= 0.38;
- }
- else if (plat == 2){
- weight *= 0.91;
- }
- else if (plat == 3){
- weight *= 0.38;
- }
- else if (plat == 4){
- weight *= 2.34;
- }
- else if (plat == 5){
- weight *= 1.06;
- }
- else if (plat == 6){
- weight *= 0.92;
- }
- else if (plat == 7){
- weight *= 1.19;
- }
- std::cout << "Your weight would be: " << weight << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement