Question
Before you start doing this code
Read carefully there is a format that you have to follow

Instructions: This program will generate some information for a user about interplanetary travel (pretend we can travel easil
INTERPLANETARY TRAVEL MENU a) Mercury b) Venus c) Earth d) Mars e) Jupiter f) Saturn g) Uranus h) Neptune q) Quit Select a pl
If the user chooses a-h, the program should then ask the user to enter their weight (ask politely) and the speed at which the
Example output (user weighs 100 lbs and wants to travel to Mercury at 50 mph): INTERPLANETARY TRAVEL: Earth to Mercury Your w
• Your code should be 1-2 pages long (3 at MOST) • Your code should not copy paste the same input, formulas and output each t

HERE IS THE FORMAT YOU MUST USE FOR HW #2 - NOTE THE IF ELSE IF...not IF IF IF

HW #2 Format :



//DECLARE ALL VARIABLES AT TOP OF MAIN 1/Sone variables you need: planetName (a string), selection (a char), weight, speed, s
}//end outer if else if (selection -- q) { //quit statements else { 1/invalid )


Planet Distance from Sun Surface Gravity as a function of Earths gravity (in millions of miles) Mercury 36 0.27 Nenus 67 10.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <math.h>

using namespace std;

int main() {

cout<<"Welcome to INTERPLANETARY TRAVEL PROGRAM!\nThis program enable you to fiind out your travel time t the planet you want to travel to as well as your weight on there. \nPlease enjoy the program and hope you'll find the perfect planet for you!"<<endl;

cout<<"INTERPLANETARY TRAVEL MENU"<<endl;

cout<<"----------------------------"<<endl;

cout<<"a) Mercury\nb) Venus\nc) Earth\nd) Mars\ne) Jupiter\nf) Saturn\ng) Uranus\nh) Neptune\nq) Quit"<<endl;

cout<<"Select a planet to travel to or q to quit the program: "<<endl;

string planetName;

double weight, speed, surfGrav, distSun, hours, min, sec;

double distSunEarth = 93;

char selection;

cin>>selection;

if(selection >= 'a' && selection <= 'h'){

double newWeight, distBetweenPlanets, travelTime;

if(selection == 'a'){

planetName = "Mercury";

surfGrav = 0.27;

distSun = 36;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

}else if(selection == 'b'){

planetName = "Venus";

surfGrav = 0.86;

distSun = 67;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

}else if(selection == 'c'){

planetName = "Earth";

surfGrav = 93;

distSun = 1.00;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

} else if(selection == 'd'){

planetName = "Mars";

surfGrav = 0.37;

distSun = 141;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

}else if(selection == 'e'){

planetName = "Jupiter";

surfGrav = 483;

distSun = 2.64;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

} else if(selection == 'f'){

planetName = "Saturn";

surfGrav = 1.17;

distSun = 886;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

} else if(selection == 'g'){

planetName = "Uranus";

surfGrav = 0.92;

distSun = 1782;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

} else if(selection == 'h'){

planetName = "Neptune";

surfGrav = 1.44;

distSun = 2793;

cout<<"your weight";

cin>>weight;

cout<<"Speed(miles per hour)";

cin>>speed;

newWeight = weight * surfGrav;

distBetweenPlanets = abs(distSunEarth - distSun);

travelTime = distBetweenPlanets * 1000000 / speed;

}

cout<<"INTERPLANETARY TRAVEL: "<<"Earth to "<<planetName<<endl;

cout<<"-------------------------------------------------"<<endl;

cout<<"Your weight on "<<planetName<<": "<<newWeight<<endl;

cout<<"Your travel time to "<<planetName<<":"<<endl;

cout<<"\tIn Hours: "<<travelTime<<endl;

cout<<"\tIn Days: "<<travelTime/24<<endl;

cout<<"\tIn Years: "<<travelTime/(365*24)<<endl;

}

}

Add a comment
Know the answer?
Add Answer to:
Before you start doing this code Read carefully there is a format that you have to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2....

    Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2. Venus 3. Earth 4. Mars 5. exit the program Enter your selection. When the user selects a planet from the menu, the program should display data about the planet's average distance from the sun, the planet's surface temperature. Use the following data in your program: Mercury Average distance from the sun ---------- 57.9 million kilometers Mass---------------3.31 x 10^23kg surface temperature------------ -173 to 430 degrees...

  • VISUAL STUDIO - WINDOWS FORM APP (C#) - PLEASE MAKE SURE TO SHOW ALL CODE &...

    VISUAL STUDIO - WINDOWS FORM APP (C#) - PLEASE MAKE SURE TO SHOW ALL CODE & ANSWER/FOLLOW ALL THE QUESTIONS IN THE ASSIGNMENT! Planet Info Help When planning this project, review the concept of accessing object properties on another form. Form2.IblMessage.Text = "1122.25" or you can put a string or object instead of numbers You can then create one form for the Planets information and set all the properties before you display the Planet Form For the pictures of the...

  • USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment...

    USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment Requirements NOTE: This program requires the use of if, elif, else, and casting between strings and numbers. The program should use the various code syntax covered in module 3. The program must result in print output using numeric input similar to that shown in the sample output below. Program: Cheese Order set values for maximum and minimum order variables set value for...

  • I want to have a code that can pick whichever two planets in the solar system and find the distance of them no matter where in their orbit they are, but I keep getting errors. Can someone please help...

    I want to have a code that can pick whichever two planets in the solar system and find the distance of them no matter where in their orbit they are, but I keep getting errors. Can someone please help me fix it? f rom scipy import exp, pi, absolute, linspace import matplotlib. Ryplot as plt planet-I input ('Which planet do you want to pick for planet 1?") planet_2 input ('which planet do you want to pick for planet 27') distance...

  • Follow instructions to create a visual C++ project, add the CH code, compile, fun and fix...

    Follow instructions to create a visual C++ project, add the CH code, compile, fun and fix errors, Write your Name, course, and date as comments on first line. Write Program's Name epp (Give it your last name with the assignment number as a name... Program0 LAST NAME). Explain what the program is to do along with any directions or instructions needed for program users (ie the purpose of each library included next to #include directive, names and uses of identifiers...etc)....

  • Code In Python Well Document Code Every Line Please * You cannot use any external Python...

    Code In Python Well Document Code Every Line Please * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...

  • Code In Python Well Document Code Every Line Please 5 Stars * You cannot use any...

    Code In Python Well Document Code Every Line Please 5 Stars * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program...

  • Code In Python Well Document Code Every Line Please * You cannot use any external Python...

    Code In Python Well Document Code Every Line Please * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work...

  • PYTHON CODE DOCUMENT EVERY LINE * You cannot use any external Python libraries. You can, of...

    PYTHON CODE DOCUMENT EVERY LINE * You cannot use any external Python libraries. You can, of course, import the libraries that are included in the standard Python installation though. * Your software must use selection (if, if/ else, etc.) and repetitive (for, while, etc) control structures and have programmer defined functions. * Make sure you understand the code you submit since you will be expected to answer questions about it. The way the program should work is the same as...

  • Programming in C with comments/steps 1. Overview The purpose of this assignment is to give you...

    Programming in C with comments/steps 1. Overview The purpose of this assignment is to give you some experience with writing functions that take in arguments and return values, as well as writing a program that consists of multiple files. This assignment also requires the use of a switch statement, in addition to more practice with printf& scanf declaring variables, using loops, and using logical expressions. For this assignment, you will prompt the user in the main function to enter their...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT