Page 1 of 1

When I run the following code: /* * To change this license header, choose License Headers in Project Properties. * To ch

Posted: Sun Jul 03, 2022 11:23 am
by answerhappygod
When I run the following code:
/** To change this license header, choose License Headers in ProjectProperties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/
package javaapplication2;
/**** @author Namburi Ramesh*/public class GasTank {private double amount=0;private double capacity;
public GasTank(double capacity) {this.capacity = capacity;}public void addGas(double a){amount=amount+a;if(amount>capacity){amount=capacity;}}public void useGas(double b){amount=amount-b;if(amount<0){amount=0;}}public boolean isEmpty(){if(amount<0.1){return true;}return false;}public boolean isFull(){if(amount>capacity-0.1){return true;}return false;}public double getGasLevel(){return amount;}public double fillUp(){double a=capacity-amount;amount=capacity;return a;}}
I get this error:
CODELAB ANALYSIS: LOGICAL ERROR(S)
Remarks:⇒ Wedid not expect but found: in classGasTank: apublic method named fillUp returning a double and accepting noparameters.More Hints:⇒ Wethink you might want to consider using: +=⇒ Wethink you might want to consider using: -=⇒ Wethink you might want to consider using: elseWant More Hints? Click here