Question
Create a Java Application CarTrip that will help you calculate the total distance from one point (point A) to a second point (point B), how
Create a Java Application "CarTrip" that will help you calculate the total distance from one point (point A) to a second point (point B), how long it will take you to get there, and if you need gas for the return trip. Use a while loop with a sentinel for this application. Use another class (MyCar class) to create car-objects and hold non-static methods. CarTrip should define the necessary variables to hold the number of gallons in the tank (must collect input at some point), the number of miles in the trip (starts at zero), current speed begins at 0). Your car will travel a consistent speed for each leg of a trip, but should change speeds for each leg (increase, decrease), and finally, determine if you need gas to complete the trip. Needs gas, implies you will need to calculate your fuel consumption, so assume your car averages 20 MPG at any speed. You must input a start fuel level.
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