Write a Java application to to ask the user to input an even

Write a Java application to to ask the user to input an even number between -100 to 100 (you can use if..else to decide the boundary) You can use either for or while loop

Solution

import java.util.*;
class CheckBound{

public static void main(String []a){

Scanner s=new Scanner(System.in);
System.out.println(\"Enter any even number between 100 to 1000\");
int input=s.nextInt();

if(input>=100 && input<=1000)
System.out.println(\"OK\");

else
System.out.println(\"Not valid number\");
}

}

Write a Java application to to ask the user to input an even number between -100 to 100 (you can use if..else to decide the boundary) You can use either for or

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site