Question: it has to be in Java, also i would like if it's only on one class. CSCI-1471-LabHomework3 (50 points, 2.5% course grade) Problem3 (25 points):
it has to be in Java, also i would like if it's only on one class.
CSCI-1471-LabHomework3 (50 points, 2.5% course grade) Problem3 (25 points): YourCar Problem. (Problem-solving process IS required, Don't Forget UML Class Diagram/s) Description: I would like you to create a Java Application "YourCarTrip" 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. You must use a while loop with a sentinel for this application. You may use a single class, or earn an extra five points for using two classes with a car class (MyCar class) to create car-objects. YourCarTrip should define the necessary variables to hold the number of gallons inthe tank (must collect input at some point), the number of miles in the trip (starts at zero), current speed (starts at zero). YourCar 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. Example Trip: Depart UHCL (point A), take a left on to Bay Area Boulevard for 3.5 miles at 30 MPH, take a left onto 145 South for 26.3 miles at 65 MPH, exit right onto 61st street, go 2.0 miles at 30 MPH to Stewart Drive, take a right and go 4.3 miles at 45 MPH to your destination on the right (point B). Example Output (you can be more creative): Are you going on a trip (1- Yes or 0 No)? 1 How many gallons of gas in your tank (Integer 1-15)? 2 Enter Leg 1 Distance (miles): 3.5 Enter Leg 1 Speed (MPH Integer]: 30 No)?1 Is there another Leg to your trip (1- Yes or 0 Enter Leg 2 Distance (miles): 26.3 Enter Leg 2 Speed (MPH Integer): 65 No)?1 Is there another Leg to your trip (1- Yes or 0 Enter Leg 3 Distance (miles): 2.0 Enter Leg 3 Speed (MPH Integer]: 30 No)?1 Is there another Leg to your trip (1- Yes or 0 Enter Leg 4 Distance (miles): 4.3 Enter Leg 4 Speed (MPH Integer): 45 Is there another Leg to your trip (1- Yes or 0 No)?0 You traveled about 36.1 miles in about 41.4 minutes. Your car will need more gas to return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
