I would like you Io create two new classes YourCar and YourC
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
*/

