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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply