Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

YourCar Application Re_Write. Description: I would like you to update the classes you created for homework3. Update YourCar and YourCarTrip such that you use a

YourCar Application Re_Write. Description: I would like you to update the classes you created for homework3. Update "YourCar" and "YourCarTrip" such that you use a for loop to enter each leg. Your application should ask the user for the number of legs for the trip, then subsequently ask for the distance and the speed limit for each leg of the trip. The input values for speed and distance will help you calculate the time required for each leg of the trip and total distance and total time for the trip. Additionally, make sure you have enough gas to make the return trip by calculating the amount of fuel needed for the return trip (please assume the same route in return). The programmer must use a 'for' loop to implement this application. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago