YourCar Application ReWrite Description I would like you to

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.

Solution

Answer:

PS: Since you haven\'t mentioned the programming language in which you want the answer, I am providing the answer here in JAVA.

Also, since YourCar and YourCarTrip are redundant classes according to my understanding, from a previous lesson/assignment, the details of which aren\'t mentioned in the question, I will be constructing the classes according to the current question.

---------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------

OUTPUT:

Please enter the current amount of fuel in the Car:10
Please enter the no. of legs in your journey:4
Leg 1
Enter Distance For Leg 1:3.5
Enter Speed For Leg 1:30
Leg 2
Enter Distance For Leg 2:26.3
Enter Speed For Leg 2:65
Leg 3
Enter Distance For Leg 3:2.0
Enter Speed For Leg 3:30
Leg 4
Enter Distance For Leg 4:4.3
Enter Speed For Leg 4:45
TRIP DETAILS
Time to travel Leg 1: 0.11666666666666667 hours
Time to travel Leg 2: 0.4046153846153846 hours
Time to travel Leg 3: 0.06666666666666667 hours
Time to travel Leg 4: 0.09555555555555555 hours

Total Time Taken For Entire Journey: 0.6835042735042735 hours
Total Distance For Entire Journey: 36.1 miles
Fuel Consumption: 2.888 Gallons
Remaining Fuel: 7.112
Need Gas: No

YourCar Application Re_Write. Description: I would like you to update the classes you created for homework3. Update \
YourCar Application Re_Write. Description: I would like you to update the classes you created for homework3. Update \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site