Question: Problem Statement: Using C Programming Write a simple code that will tell you how much you weigh on every planet. What I have so far:

Problem Statement: Using C Programming

Write a simple code that will tell you how much you weigh on every planet.

What I have so far:

Formula: Weight on Earth * Surface Gravity of planet

Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune
0.38 0.91 1.0 0.38 2.14 0.91 0.86 1.1

Algorithum: 1. prompt user to input their weight on planet Earth

2. Test user's input to make sure input is > 0

3. Give user a menu that allows user to select which planet they would like to know their weight on

Code written so far: #include

float Woop(float weight); //Woop stands for Weight on other Planets

float planets[] = {0.38, 0.91, 1.0, 0.38, 2.34, 1.06, 0.92, 1.19}; //Array of each planet's surface gravity

int p;

int main ()

{ printf("Please enter your weight on Earth in pounds.")

scanf("%f", &w);

if (weight > 0) //Test input

printf(" 1. Mercury"); printf(" 2. Venus"); printf(" 3. Earth"); printf(" 4. Mars"); printf(" 5. Jupiter"); printf(" 6. Saturn"); printf(" 7. Uranus"); printf(" 8. Neptune"); //Menu

scanf(" %f ", &p ); //User's choice of planet

else

{ printf("Weight entered is incorrect. Please try again."); }

return 0:

}

Your help is very much appreciated. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!