Write a menu driven program in Java using switch case to accept and check whether a number is
a) spy number
b) prime number or not
print an error message for an invalid output.
URGENT! full program please.
Answers
Answered by
0
Answer:
public class JavaExample {
public static void main(String[] args) {
int num = 370, number, temp, total = 0;
number = num;
while (number != 0)
{
temp = number % 10;
total = total + temp*temp*temp;
number /= 10;
}
if(total == num)
System.out.println(num + " is an Armstrong number");
else
System.out.println(num + " is not an Armstrong number");
}
}
Output:
370 is an Armstrong number
Similar questions