Question
Description: Update YourCar and YourCarTrip such that you use a two-dimensional array to store each leg. Your application should store all legs for the trip
Description: Update "YourCar" and "YourCarTrip" such that you use a two-dimensional array to store each leg. Your application should store all legs for the trip in multiple arrays, including the distance and the speed limit for each leg of the trip. The rest of the requirements are the same as previous homework. Outputs should include, but are not limited to: time to travel each leg, total time, total distance, fuel consumption and remaining fuel.
Original
Description: Update "YourCar" and "YourCarTrip" such that you use multiple arrays to store each leg. Your application should store all legs for the trip in multiple arrays, including the distance and the speed limit for each leg of the trip. The rest of the requirements are the same as previous homework. Outputs should include, but are not limited to: time to travel each leg, total time, total distance, fuel consumption and remaining fuel.
Example: Depart UHCL (point A), take Bay Area Boulevard for 3.5 miles at 30 MPH, take I45 South for 26.3 miles at 65 MPH, exit right onto 61st street and go 2.0 miles at 30 MPH, then take Stewart Drive 4.3 miles at 45 MPH to your destination (point B). You application should ask the user for the number of legs (this case four (4)) then loop through four sets of questions to gather the necessary inputs for distance and speed.
YourCar should define, at least, the instance variables that hold the number of gallons in the tank (must be input at some point), the number of miles in the trip (starts at zero), current speed (starts at zero). YourCar should have the ability (methods) to change speed (increase, decrease), calculate time, calculate distance traveled, and determine if you need gas. Needs gas, implies you will need to calculate your fuel consumption, so assume your car averages 25 MPG at any speed. You may have to ask the user for amount of fuel (gallons) at the beginning of the trip. Constraint: Your gas tank cannot hold over 10 gallons.
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