Results 1 to 2 of 2
  1. #1
    jacjacjac is offline Member
    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0

    Default Incompatible types?

    This is the error I keep getting:
    Java 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:
    Java 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?

  2. #2
    Lowest0ne is offline Member
    Join Date
    Apr 2012
    Posts
    21
    Rep Power
    0

    Default Re: Incompatible types?

    Line 8 defines status as an int, but you treat it like a boolean in line 17 and 19.

Similar Threads

  1. incompatible types?
    By slider57 in forum New To Java
    Replies: 3
    Last Post: 09-26-2012, 12:55 PM
  2. Incompatible types
    By Yokomoko in forum New To Java
    Replies: 10
    Last Post: 07-10-2012, 03:49 AM
  3. incompatible types
    By angelicatomnob in forum New To Java
    Replies: 3
    Last Post: 01-17-2012, 03:25 PM
  4. incompatible types!!
    By sneha343 in forum New To Java
    Replies: 7
    Last Post: 11-30-2011, 11:49 PM
  5. incompatible types
    By effa in forum New To Java
    Replies: 16
    Last Post: 02-03-2011, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •