write a program in java to input any number and check whether the number is equal to 111 or not. if the number is equal to 111 then print “nelson number” otherwise print“not a nelson number”.
Answers
Answered by
1
Answer:
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner myVar = new
Scanner(System.in);
int n = myVar.nextInt();
if(n==111){
System.out.println("nelson number");
}else{
System.out.println("not a nelson number");
}
}
}
Explanation:
this asks user to enter a value, if the number is 111 it prints 'nelson number' otherwise 'not a nelson number'
Similar questions