please tel the program see the questions in image and tell please fast it's urgent
please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please please
iam in need
Answers
Answer:
import java.util.Scanner;
import java.io.*;
public class NumCheck {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter a number maximum 9 digit");
int num =input.nextInt();
System.out.println("Enter the digit according to your choice 1 or 2 or 3 or 4 to check the number what you have entered");
System.out.println("1.for checking primeNumber");
System.out.println("2. for checking Armstrong Number");
System.out.println("3. for checking Palindrome Number");
System.out.println("4. for checking Perfect Number");
System.out.println("enter your choice :");
int a= input.nextInt();
switch (a){
case 1:
int perfectNo = 0;
int i;
System.out.println("Factors are:");
for (i = 1; i < num; i++) {
if (num % i == 0) {
perfectNo += i;
System.out.println(i);
}
}
if (perfectNo == num) {
System.out.println("number is a perfect number");
}
else
{
System.out.println("number is not a perfect number");
}
case 2:
int x;
System.out.println("Enter an integer to check if it is odd or even");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if (x % 2 == 0)
System.out.println("The number is even.");
else
System.out.println("The number is odd.");
}
}
}
Explanation:
hope it will help