You need to write a program that reads in the mass of an object (in kg) and output the weight (in N) on the Earth, on the Moon, and on Venus. An object's mass can be measured in kilograms. The weight is measured in newtons. So an object of a specific mass (in kilograms) would have one weight (in newtons) on the earth and a different weight on the moon. Your program will read in the mass (in kilograms) and convert it to newtons for the Earth, the Moon, and Venus. So, on the Earth we can convert kilograms to newtons with the following expression: weight = mass * 9.81 where 9.81 is the acceleration due to gravity on earth (in meters per second squared or m/s^2). On the Moon this formula would be: weight = mass * 1.62 where 1.62 is the acceleration due to gravity on the moon (m/s^2) Finally, for Venus it would be: weight = mass * 8.87

Respuesta :

Answer:

#include <iostream>

#include<iomanip>

using namespace std;

int main()

{

double mass,e,m,v;

cout<<"Enter the mass : ";

cin>>mass;

cout<<"The mass is "<<mass<<" kg\n";

if(mass<=0){

cout<<" mass must be greater than zero";

return 0;

}

e= mass * 9.81;

m= mass * 1.62;

v = mass * 8.87;

cout.setf(ios::fixed);

cout<<"Location"<<right<<setw(10)<<"Weight\n";

cout<<"Earth"<<right<<setw(15)<<setprecision(4)<<e<<endl;

cout<<"Moon"<<right<<setw(15)<<setprecision(4)<<m<<endl;

cout<<"Venus"<<right<<setw(15)<<setprecision(4)<<v<<endl;

cout<<endl<<endl;

if(m>=1500)

cout<<"Object is light weight";

else

cout<<"Object is heavy weight";

}

Explanation:

The program is a sequential program, and it does not require loops or conditional statements.

The program in Python is as follows, where comments are used to explain each line:

#This gets input for the mass of the object

mass = float(input("Mass: "))

#This calculates the weight of the object on Earth

Earth = mass * 9.81

#This calculates the weight of the object in Mars

Mars= mass * 1.62

#This calculates the weight of the object in Venus

Venus = mass * 8.87

#This prints the weight of the object on earth

print("Weight on Earth: {:.2f}".format(Earth))

#This prints the weight of the object in Mars

print("Weight on Mars: {:.2f}".format(Mars))

#This prints the weight of the object in Venus

print("Weight on Venus: {:.2f}".format(Venus))

At the end of the program, the weights are printed to two decimal places.

Read more about similar programs at:

https://brainly.com/question/19688338

ACCESS MORE