Log in

View Full Version : What's wrong with this


albear
Oct 12, 2007, 01:49 AM
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");


}
}

albear
Oct 12, 2007, 05:36 AM
Please...

benn11
Oct 12, 2007, 05:48 AM
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"

albear
Oct 12, 2007, 05:53 AM
I agree but you've put if Num is less than 10, ill try it and see

albear
Oct 12, 2007, 05:56 AM
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

qcumber
Nov 14, 2007, 09:33 PM
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");
}