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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started