write program in Java which will accept a number check and display whether it is nelson number or not
Answers
Answered by
3
Answer:
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int n;
System.out.println("Enter a number");
n=in.nextInt();
if(n%111==0)
System.out.println("It is a nelson number");
else
System.out.println("It is not a nelson number");
}
}
Output
- The first photo is the output for a nelson number.
- The second photo is the output for a non nelson number.
Concept:-
- A nelson number is a number that is divisible by 111.
Attachments:
Similar questions
Math,
1 month ago
Math,
2 months ago
Math,
2 months ago
Science,
9 months ago
Computer Science,
9 months ago