Write a script named MoonWeight.m that prompts the user for their weight in poun
ID: 3812077 • Letter: W
Question
Write a script named MoonWeight.m that prompts the user for their weight in pounds on Earth and then displays their mass and how much they would weigh on the moon.
Use appropriately-named variables to represent masses, to represent the radius of the Moon, and for conversion factors.
Constants should be all-caps, e.g. MASS_OF_MOON Assume 1 pound mass (lbm) = 0.454 kilograms.
Assume 1 pound mass exerts 1 pound force (lbf) of force at your location on Earth.
Use your script compute_gravitational_force to compute the gravitational forces.
Test case: Someone who weighs 132 lbf on Earth would weigh 21.86 lbf on the Moon, which has a mass of 7.34767309e22 kg and a radius of 1737400 m.
Output should be formatted to look like Your mass is 59.93 kg. You would weigh 21.86 lbs on the Moon.
Your script must be commented, including the header and help comments.
MatLab
Explanation / Answer
Matlab code:-
G=6.67*(10.^(-11));
MASS_OF_THE_MOON=7.35*(10.^22);
> RADIUS=1737400;
weight_earth=input('Enter your weight on earth in pounds :');
weight_earth_kg=weight_earth*ONE_POUND_TO_KG;
disp('You weigh on earth in kgs :');
disp(weight_earth_kg);
mass_earth_kg=weight_earth_kg/9.8;
gravity_on_moon=(G*MASS_OF_THE_MOON)/(RADIUS*RADIUS);
weight_moon_kg=mass_earth_kg*gravity_on_moon;
mass_moon=weight_moon_kg/ONE_POUND_TO_KG;
disp('weigh on moon in lbs : ');
disp(mass_moon);
OUTPUT:-
Enter your weight on earth in pounds :132
You weigh on earth in kgs :
59.928
weigh on moon in lbs :
21.876
sh-4.3$
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.