
In order to have success in this assignment, you need to have completed Road Trip Part 1.
MAKE A COPY OF PART 1. YOU WILL LOSE POINTS IF YOU DON’T MAKE A COPY.
-
To make a copy of Part 1, open your Part 1 program.
-
Click on “File, Save as a copy”
-
Name your new copy with your last name like Milstead Road Trip 2. But use your own last name.
Here’s what you are adding to Road Trip Part 2:
-
INPUT: how many people are in your car (including driver).
-
CALCULATE: cost per person – what they owe you for gas money.
-
OUTPUT: how much each person will pay for gas.
-
OUTPUT:”you will need to stop with (miles remaining) before you reach your destination” OR tell them “You will be able drive your trip distance of (distance) and have (range-distance) miles left of range”.
Let’s break it down:
INPUT: how many people are in your car (including driver).
Create a variable for the number of people in the car.
Ask the user for this number.
CALCULATE: cost per person – what they owe you for gas money.
cost per person = total fuel cost/passengers
OUTPUT: how much each person will pay for gas.
A statement that says “You have (number of passengers) passengers. Each person will pay (cost per person) dollars for gas money.
OUTPUT:tell your user “you will need to stop with (miles remaining) before you reach your destination” OR tell them “you will not need to stop for gas!”.
Use an if/else statement.
if total distance is greater than range:
say “You are driving (total distance) and will need to stop (distance – range) miles away from your destination to get gas.
what do you have your program say for the else statement if you don’t have to stop for gas? Use the above formula to get started.
Here’s what the output will look like, depending on if the car will have to stop or not:



