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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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:
1
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
1
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:
1
hours = hoursWorked;
Line 59 needs parentheses around "getHours() - 40".
You need to login to post a reply.