Allow the user to input their weight for the earth weight to moon weight convers
ID: 3577763 • Letter: A
Question
Allow the user to input their weight for the earth weight to moon weight conversion problem. Add an if statement that prompts the user if she inputs 0 or a negative number for her earth weight.
Add single and multi-line comments to your code so that people looking into your program understand the things you are attempting to do with each section of code.
Use Object Orientated Design (OOP),
Use Constructors, Parameters, and arguments as needed.
Create 1 method that sets the value for weight
Write a program that has 4 methods that will return the weigth conversions for the following.
1 method will convert Weight on Earth’s Moon .
1 method will convert Weight on Mars
1 method will convert Weight on Venus
1 method will convert Weight on Mercury
Create a menu that gives the user choice and con
Show number of seconds, converted to hours, converted to minutes, and remaining seconds.
Attach Source Code photo
Attach output of both methods being run.
OUTPUT should looks like this
128
***********************************************************
* Main Menu: *
* Enter # to run program or Quit *
* 1) Calculate Weight on Mercury *
* 2) Calculate Weight on Venus *
* 3) Calculate Weight on Earth’s Moon *
* 4) Calculate Weight on Mars *
* 5) Quit *
**********************************************************
Explanation / Answer
lets me do it with C++
int weight_on_mercury(int rd)
{
rd=rd*360*24*60*60;
return rd;
}
int weight_on_venus(int rd)
{
rd=rd*360*24;
return rd;
}
int weight_on_moon(int rd)
{
rd=rd*360*24*60;
return rd;
}
int weight_on_mars(int rd)
{
rd=rd*360*24*60*60;
return rd;
}
void main()
{
int weight,choice;
cout<<"1.Calculate weight on Mercury 2. Calculate weight on Venus 3. Calculate Weight on Earth's Moon 4.Calculate Weight on Mars 5.Quit<<endl";
cin>>choice>>weight;
do
{
switch(choice)
{
case 1: cout<<"calculate weight on mercury:";
int b=weight_on_mercury(weight);
cout<<b<<endl;
break;
case 2: cout<<"calculate weight on Venus";
int b=weight_on_venus(weight);
cout<<b<<endl;
break;
case 3: cout<<"calculate weight on Earth's MOOn";
int b=weight_on_moon(weight);
cout<<b<<endl;
break;
case 4: cout<<"calculate weight on Mars";
int b=weight_on_mars(weight);
cout<<b<<endl;
break;
}
}while(choice!=5);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.