-
Incompatible types?
This is the error I keep getting:
Code:
payRoll.java:17: error: incompatible types
status = true;
^
required: int
found: boolean
payRoll.java:19: error: incompatible types
status = false;
^
required: int
found: boolean
2 errors
This is my code:
Code:
import java.util.Scanner;
public class payRoll
{
public static void main(String[] args)
{
int payRate;
int status;
Scanner keyboard = new Scanner(System.in);
do
{
System.out.println("Enter the hourly pay rate");
payRate = keyboard.nextInt();
}
while (payRate>7.5 && payRate<18.25);
if(payRate>7.5 && payRate<18.25)
status = true;
else
status = false;
System.out.println("You have entered an invalid number");
}
}
Why do I get those errors?
-
Re: Incompatible types?
Line 8 defines status as an int, but you treat it like a boolean in line 17 and 19.