Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that will calculate your weight on Mercury, Venus, Mars, and Ea

ID: 3871654 • Letter: C

Question

Create a program that will calculate your weight on Mercury, Venus, Mars, and Earth’s moon.Update your previous program.

Create independent return functions that calculate each planetary body independently.

In main() create a menu that controls the program.

The program should bring receive input only in main() and pass values to other parts of the program.p[

Label the output so it is clear your weight on each independent planetary body.

If the user inputs a weight that is 0 or less the 0, the program should prompt the user “Invalid Weight” and stop execution.

Update your program to prompt the user for a second Integer input if the initial value for weight is valid. The input will correspond to the values the user wants to output.

(Use nested if statements and if else ladder to accomplish the task.)

Program should contain a menu.

Enter 1. For Mercury Weight

(After the user enters 1 the program will output weight converted to Mercury weight. )

Enter 2. For Venus Weight

(After the user enters 1 the program will output weight converted to Venus weight. )

Enter 3. For Mars Weight

Enter 4. For Earth's Moon weight

Enter 5: For all Conversions

Please be clear with comments and follow the guidelines throughly(return functions needed). It should be in c++. Thanks for your help

Explanation / Answer

#include <iostream>

using namespace std;

int weightOnMercuryCal(int weight){
   int weightOnMercury;
   weightOnMercury = 0.38 * weight; //calculates weight on Mercury.
   return weightOnMercury; //return to main()
}
int weightOnVenusCal(int weight){
   int weightOnVenus;
   weightOnVenus = 0.91 * weight; //calculates weight on Venus.
   return weightOnVenus; //return to main()
}
int weightOnMarsCal(int weight){
   int weightOnMars;
   weightOnMars = 0.38 * weight; //calculates weight on Mars.
   return weightOnMars; //return to main()
}
int weightOnMoonCal(int weight){
   int weightOnMoon;
   weightOnMoon = 0.167 * weight; //calculates weight on Moon.
   return weightOnMoon; //return to main()
}

int main( ) {
   int weight,num,retWeight;
   cout<<"Enter Your Weight: ";
    cin>>weight;
   if(weight<=0){
       cout<<"Invalid Weight: /n";
       return 0; // Exit from the system.
   }
   else{
       cout<< "Enter 1. For Mercury Weight/n";
       cout<<"Enter 2. For Venus Weight/n";
       cout<<"Enter 3. For Mars Weight/n";
       cout<<"Enter 4. For Earth's Moon weight/n";
       cout<<"Enter 5: For all Conversions/n";
       cout<<"Enter Your Choice/n";
       cin>>num;
       if(num == 1){ //Calling weightOnMercuryCal()
           retWeight = weightOnMercuryCal(weight);
           cout<<"Your Weight on Mercury is: "<<retWeight;
       }
       else if(num == 2){ //Calling weightOnVenusCal()
           retWeight = weightOnVenusCal(weight);
           cout<<"Your Weight on Venus is: "<<retWeight;
       }
       else if(num == 3){ //Calling weightOnMarsCal()
           retWeight = weightOnMarsCal(weight);
           cout<<"Your Weight on Mars is: "<<retWeight;
       }
       else if(num == 4){ //Calling weightOnMoonCal()
           retWeight = weightOnMoonCal(weight);
           cout<<"Your Weight on Earth's Moon is: "<<retWeight;
       }
       else if(num == 5){ // Calling all the functions
           retWeight = weightOnMercuryCal(weight);
           cout<<"Your Weight on Mercury is: "<<retWeight;
           retWeight = weightOnVenusCal(weight);
           cout<<"Your Weight on Venus is: "<<retWeight;
           retWeight = weightOnMarsCal(weight);
           cout<<"Your Weight on Mars is: "<<retWeight;
           retWeight = weightOnMarsCal(weight);
           cout<<"Your Weight on Mars is: "<<retWeight;          
       }  
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote