Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   What's wrong with this (https://www.askmehelpdesk.com/showthread.php?t=139848)

  • Oct 12, 2007, 01:49 AM
    albear
    what's wrong with this
    reet, its meant to tell you if the number that the user inputs is between the range but for some reason it doesn't like it. Any help would be great.

    import java.util.*; // the package containing Scanner
    public class Range
    {
    public static void main(String[] args)
    {

    Scanner kybd = new Scanner(System.in);

    //input

    System.out.println("Enter an integer");
    int Num1;
    Num1 = kybd.nextInt();

    //calculations and output

    If ((10 <= Num1)&&(Num1<=50) )

    System.out.println("The Integer is between 10 and 50" );

    Else

    System.out.println("The integer is not within the boundaries");


    }
    }
  • Oct 12, 2007, 05:36 AM
    albear
    Please...
  • Oct 12, 2007, 05:48 AM
    benn11
    Try this

    If ((10 >= Num1)&&(Num1<=50) )

    System.out.println("The Integer is between 10 and 50" ); //because the integer should be more than 10 and less than 50 to be "bettween 10 and 50"
  • Oct 12, 2007, 05:53 AM
    albear
    I agree but you've put if Num is less than 10, ill try it and see
  • Oct 12, 2007, 05:56 AM
    albear
    Nope still doesn't like it. Itstill has the same erors either way around

    It has a problem with the if part on wards

    Thanks for answering
  • Nov 14, 2007, 09:33 PM
    qcumber
    If ((10 <= Num1)&&(Num1<=50) )
    {
    System.out.println("The Integer is between 10 and 50" );
    }
    else
    {
    System.out.println("The integer is not within the boundaries");
    }

  • All times are GMT -7. The time now is 09:08 AM.