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

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: /* * To change this license header, choose License Headers in Project Properties. * To ch

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