when I input a number that is less than -5 it prints off 'this number is valid' and 'this number is invalid'
I know its because of where its placed but how can I prevent it so that it only brings up one message.
import java.util.*; // the package containing Scanner
public class Ranges
{
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 (Num1 < -5)
{
System.out.println("Number is valid");
}
if ( (Num1 >= 4)&&(Num1 <= 12))
{
System.out.println("Number is valid");
}
else
{
System.out.println("Number is invalid");
}
}
}