This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2021/7/3

where is the boolean?

divinity divinity

2021/7/3

#
hi danpost: I am doing another one of my practice program and I am an error as usual. There is: incompatible types: boolean cannot be converted to double, i have been for the life of me trying to find where is the boolean part of it but i cannot see it. can u tell me where it is and how to fix it. here is the codes.
public  class HourlyEmployee extends Employee {
    
    String firstname;
    double hourlywage;
    float rate;
    double comPay;
    double hourlyWage; 
    double hoursWorked;
    double totalpay=0;
    double wage;
    double hours;

    public HourlyEmployee(String firstname, double hourlywage) {
        
        super(firstname, hourlywage);
        setWage(hourlyWage);
        setHours(hoursWorked);
        
    }
    
    public  double comPay(){
        
        return 0;
        
    }
    public String getfirstname(){
        return firstname;
    }
    public double gethourlywage(){
        return hourlywage;
    }
    public void setfirstname(String firstname){
        this.firstname = firstname;
    }
    public void sethourlywage(double hourlywage){
        this.hourlywage = hourlywage;
    }
      public double getWage(){
        return wage;
    }

     public void setWage(double hourlyWage) {
      // wage =
    }
     public double getHours() {
        return hours;
    }
  
    public void setHours(double hoursWorked){
      
      totalpay = (hoursWorked >= 40) && (hoursWorked <= 1.5); there is where the error is: (incompatible types: boolean cannot be converted to double) that is the error 
          
    }
    
    public double earnings(){
      if(getHours()<=40)       
       
      return getWage()* getHours();
     return 40 * getWage() +(getHours() - 40 * getWage() * 1.5);
       
    }
    
    @Override
    public String toString(){
        return "Employees details"+ " "+ "First name is "+ firstname+""+"Hourlywage is "+hourlywage;
    }
Gbasire Gbasire

2021/7/3

#
do : totalpay = ((hoursWorked >= 40) && (hoursWorked <= 1.5));
danpost danpost

2021/7/3

#
Remove lines 8 and 17. Then change line 51 to:
hours = hoursWorked;
Line 59 needs parentheses around "getHours() - 40".
divinity divinity

2021/7/4

#
gbasire I am still getting the error: incompatible types: boolean cannot be converted to double on this codes
 totalpay = ((hoursWorked >= 40) && (hoursWorked <= 1.5));
: am still getting this error here with this line of code: totalpay = ((hoursWorked >= 40) && (hoursWorked <= 1.5)); do I remove or how to fix it
danpost danpost

2021/7/4

#
divinityI wrote...
: am still getting this error here with this line of code: totalpay = ((hoursWorked >= 40) && (hoursWorked <= 1.5)); do I remove or how to fix it
danpost wrote...
Remove lines 8 and 17. Then change line 51 to:
hours = hoursWorked;
Line 59 needs parentheses around "getHours() - 40".
You need to login to post a reply.