Answer:
See explaination
Step-by-step explanation:
class Car
{
private double drdist;
private double fuel;
private double mpg;
public Car(double m)
{
mpg = m;
fuel = 0;
}
public void addGas(double add)
{
fuel = fuel + add;
}
public void drive(double d)
{
drdist = drdist + d;
mpg = fuel * mpg / d;
}
public double getGasLevel()
{
return fuel;
}
}
public class Carfuel{
public static void main(String []args){
Car myHybrid = new Car(50); //50 miles per gallon
myHybrid.addGas(20); // Tank 20 gallons
myHybrid.drive(100); // Drive 100 miles
System.out.println(myHybrid.getGasLevel()); // Print fuel remaining.
}
}