I would like you Io create two new classes YourCar and YourC

I would like you Io create two new classes \'YourCar\' and \"YourCarTrip\" that will help you calculate the total distance from one point (point A) to a secured point (point R), how long it will take you to get there, and if you need gas for the return trip. YourCarTrip is the application. Depart UH (point A), take a left on to Baytown Boulevard for i.b miles at 30 MPH, take a left onto 4s south for 26.3 miles at 6s MPH, exit right onto 61st street, go 2.0 miles to Stewart Drive, take a right and go 4.3 miles at 45 MPH to your destination on the right 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 also be able to change direction, charge speed (increase, decrease), and determine ill you need gas. Meds gas, implies you will need to calculate your fuel so assume Yom car averages 25 MPG at any speed. Would like you to run two different YourCar objects at the tame time to see if it is worth the time to go ten miles over the speed limit, so, your application should output, the route (changes in course), the total distance, the total time, and fuel consumption. There should be one text document that provides the problem-solving methodology. Each Step of the Engineering Problem Solving Process needs to be documented. I. (10%) Understand the Problem. II. (10%) Design, 111. (70%) Implementation (Code), IV (10%) Test Plan.

Solution

// YourCar.java
class YourCar
{
double totalGas = 0;
double totalmiles = 0;
double currentSpeed = 0;
}


//YourCarTrip.java
import java.util.*;

public class YourCarTrip
{
public static void main(String[] args)
{
double carAverage = 25;

Scanner scan=new Scanner(System.in);

YourCar c1= new YourCar();
YourCar c2= new YourCar();
double t1,t2;

System.out.print(\"Enter the number of gallons of gas in the tank for car 1: \");
c1.totalGas = scan.nextDouble();
  
System.out.print(\"Enter the number of gallons of gas in the tank for car 2: \");
c2.totalGas = scan.nextDouble();

c1.totalmiles=(3.5+26.3+2.0+4.3);
c2.totalmiles=(3.5+26.3+2.0+4.3);

t1=(3.5/30) + (26.3/65) + (4.3/45);
t2=(3.5/20) + (26.3/55) + (4.3/35);

c1.currentSpeed=(30+65+45)/3;
c2.currentSpeed=(20+55+35)/3;

System.out.println(\"\ Route 1: Depart UHCL (point A), take a left on to Bay Area Boulevard\ for 3.5 miles at 30 MPH, take a left onto I45 South for 26.3 miles at 65 MPH,\ exit right onto 61st street, go 2.0 miles to Stewart Drive, take a right\ and go 4.3 miles at 45 MPH to your destination on the right (point B).\");
System.out.println(\"\ Car 1: \ Total distance covered: \"+ c1.totalmiles+\" miles\");
System.out.println(\"Total time taken: \"+ t1+\" hrs\");
System.out.println(\"Current Speed: \"+ c1.currentSpeed+\" MPH\");
System.out.println(\"Gas Required: \"+ (c1.totalGas-2 * (c1.totalmiles/carAverage))+\" gallons\");

if((c1.totalGas-2*(c1.totalmiles/carAverage)) >=0 )
{
System.out.println(\"Your car don\'t need any gas\ \");
}
else
System.out.println(\"Your car do need gas\ \");


System.out.println(\"\ Route 2: Depart UHCL (point A), take a left on to Bay Area Boulevard\ for 3.5 miles at 40 MPH, take a left onto I45 South for 26.3 miles at 75 MPH,\ exit right onto 61st street, go 2.0 miles to Stewart Drive, take a right\ and go 4.3 miles at 55 MPH to your destination on the right (point B).\");
System.out.println(\"\ Car 2:\ Total distance: \"+ c1.totalmiles+\" miles\");
System.out.println(\"Total time: \"+ t2+\" hrs\");
System.out.println(\"Current Speed: \"+ c2.currentSpeed+\" MPH\");
System.out.println(\"Gas Required: \"+ (c2.totalGas-2 * (c1.totalmiles/carAverage))+\" gallons\");

if((c2.totalGas-2*(c2.totalmiles/carAverage)) >=0 )
{
System.out.println(\"Your Car don\'t need any gas\ \");
}
else
System.out.println(\"Your Car do need gas\ \");
  
}
}   


/*
output:

Enter the number of gallons of gas in the tank for car 1: 5
Enter the number of gallons of gas in the tank for car 2: 15

Route 1: Depart UHCL (point A), take a left on to Bay Area Boulevard
for 3.5 miles at 30 MPH, take a left onto I45 South for 26.3 miles at 65 MPH,
exit right onto 61st street, go 2.0 miles to Stewart Drive, take a right
and go 4.3 miles at 45 MPH to your destination on the right (point B).

Car 1:
Total distance covered: 36.1 miles
Total time taken: 0.6168376068376068 hrs
Current Speed: 46.0 MPH
Gas Required: 2.112 gallons
Your car don\'t need any gas


Route 2: Depart UHCL (point A), take a left on to Bay Area Boulevard
for 3.5 miles at 40 MPH, take a left onto I45 South for 26.3 miles at 75 MPH,
exit right onto 61st street, go 2.0 miles to Stewart Drive, take a right
and go 4.3 miles at 55 MPH to your destination on the right (point B).

Car 2:
Total distance: 36.1 miles
Total time: 0.7760389610389611 hrs
Current Speed: 36.0 MPH
Gas Required: 12.112 gallons
Your Car don\'t need any gas

*/

 I would like you Io create two new classes \'YourCar\' and \
 I would like you Io create two new classes \'YourCar\' and \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site