![subject](/tpl/images/cats/ap.png)
Advanced Placement (AP), 23.10.2020 01:01 fabiolabaritto
Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank, and addGas, to add gasoline to the fuel tank. Sample usage: Car myHybrid = new Car(50); // 50 miles per gallon myHybrid. addGas(20); // Tank 20 gallons myHybrid. drive(100); // Drive 100 miles double gasLeft = myHybrid. getGasInTank(); // Get gas remaining in tank You may assume that the drive method is never called with a distance that consumes more than the available gas. Supply a CarTester class that tests all methods.
This is my code, please help me fix it:
Car. java
public class Car {
// Instant Fields
private double gas;
private double efficiency;
// Constructor
public Car(double fe) {
fuelEff = fe;
gas = 0;
}
// Methods
public void addGas(double amount) {
gas = gas + amount;
}
public void drive(double distance) {
drive = drive + distance;
gas = gas - (distance / milesPerGallon);
}
public double getGasInTank() {
return gas;
}
}
Tester
class Main {
public static void main(String[] args) {
//E3.12 car
carTester();
public static void carTester() {
Car myHybrid = new Car(50);
myHybrid. addGas(20);
myHybrid. drive(100);
double gasLeft = myHybrid. getGasInTank();
System. out. println("Gas Left: " + gasLeft);
}
}
![ansver](/tpl/images/cats/User.png)
Answers: 2
Another question on Advanced Placement (AP)
![question](/tpl/images/cats/ap.png)
Advanced Placement (AP), 23.06.2019 12:00
True or false. in studies examining gender differences and juvenile crime, recent research has shown that the gender gap for drug and violent offenses is getting smaller.
Answers: 1
![question](/tpl/images/cats/ap.png)
Advanced Placement (AP), 23.06.2019 12:20
Write in detail! will give free points 30 + free ! looking at the red mustang on the left, and the blue prius on the right, explain which vehicle should be given right-of-way at this intersection.
Answers: 1
![question](/tpl/images/cats/ap.png)
Advanced Placement (AP), 24.06.2019 07:30
Which of these statements properly demonstrates the angle addition postulate for the m∠afc m∠afc ? a. m∠afc=m∠afb+m∠bfd m∠afc=m∠afb+m∠bfd b. m∠afc=m∠afb+m∠bfc m∠afc=m∠afb+m∠bfc c. m∠afc=m∠cfd+m∠dfe m∠afc=m∠cfd+m∠dfe d. m∠afc=m∠afb+m∠dfc+m∠cfb m∠afc=m∠afb+m∠dfc+m∠cfb
Answers: 2
![question](/tpl/images/cats/ap.png)
Advanced Placement (AP), 25.06.2019 20:00
In 2009, florida suffered more fatalities than any other state. a. bicyclist b. child passenger c. pedestrian d. impaired driving
Answers: 1
You know the right answer?
Implement a class Car with the following properties. A car has a certain fuel efficiency (measured i...
Questions
![question](/tpl/images/cats/biologiya.png)
Biology, 17.09.2019 18:00
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/health.png)
Health, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/fizika.png)
Physics, 17.09.2019 18:00
![question](/tpl/images/cats/biologiya.png)
Biology, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 17.09.2019 18:00
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/health.png)
Health, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/fizika.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00
![question](/tpl/images/cats/mat.png)
Mathematics, 17.09.2019 18:00