Page 1 of 1

When I run the following code: public class GasTank { private double amount = 0; private double capacity; public GasTan

Posted: Sun Jul 03, 2022 11:22 am
by answerhappygod
When I run the following code:
public class GasTank {private double amount = 0;private double capacity;public GasTank(double i) {capacity = i;}public void addGas(double i) { amount += i; if(amount >capacity) amount = capacity; / amount = amount <capacity ? amount+i : capacity;/ }public void useGas(double i) { amount = amount < 0 ? 0 : amount- i; }public boolean isEmpty() { return amount < 0.1 ? true : false;}public boolean isFull() { return amount > (capacity-0.1) ? true: false; }public double getGasLevel() { return amount; }public double fillUp() { double blah = capacity - amount; amount =capacity; return blah; }}
I get this error:
CODELAB ANALYSIS: COMPILER ERROR(S)
More Hints:⇒ Ihaven't yet seen a correct solution that uses:/Want More Hints? Click here⇒ CompilerError