can you please help. i think i am using else wrongly. i am trying to setup a when a user type in a number it printer out even number within range. but if they hit type more than say 40 i want it to print out "number out of range,
import java.util.Scanner;
public class ModulusCalculation
{
public static void main(String[] args)
{
System.out.println("ENTER RANGE OF EVEN NUMBERS TO FIND ");
Scanner scan = new Scanner(System.in);
for (int startingPoint = scan.nextInt(); startingPoint <= 40; startingPoint++)
{
if (startingPoint % 2 == 0)
{
System.out.println(+startingPoint);
else
System.out.println("THIS IS OUT OF RANGE");
}
}
}
}
import java.util.Scanner;
public class ModulusCalculation
{
public static void main(String[] args)
{
System.out.println("ENTER RANGE OF EVEN NUMBERS TO FIND ");
Scanner scan = new Scanner(System.in);
for (int startingPoint = scan.nextInt(); startingPoint <= 40; startingPoint++)
{
if (startingPoint % 2 == 0)
{
System.out.println(+startingPoint);
else
System.out.println("THIS IS OUT OF RANGE");
}
}
}
}