Write a Java program to check whether a number is an Armstrong Number or not. Armstrong (Michael F. Armstrong) number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers Sample Solution: Java Code: importj...
Java program to print Rhombus star pattern program. We have written the below print/draw Rhombus star pattern program in four different ways with sample example and output, do check it out. At the end of the program, we have added the compiler so that you can execute the below codes. ...
System.out.println("Input string is a palindrome.");elseSystem.out.println("Input string is not a palindrome."); } } 输出1: Enter a string to checkifit is a palindrome: aabbaa Input string is a palindrome. 输出2: Enter a string to checkifit is a palindrome: aaabbb Input string is ...
Write a Java program to check whether a given number is a happy number or unhappy number. Happy number: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1, or it loops endlessly in a cycle whi...
Patterns in Java, Star Patterns in Java, Number Patterns in Java, Swapping in Java, Factorial in Java, Fibonacci Series in Java, Reverse Number in Java, Palindrome in Java, Armstrong Number in Java, Squares in Java, Square Root in Java, Special Number in Java, Anagram Program in Java, St...
Patterns in Java, Star Patterns in Java, Number Patterns in Java, Swapping in Java, Factorial in Java, Fibonacci Series in Java, Reverse Number in Java, Palindrome in Java, Armstrong Number in Java, Squares in Java, Square Root in Java, Special Number in Java, Anagram Program in Java, St...
The program prints whether the number is a Strong Number or not. Example Outputs Example 1 Input: 145 Output Example 2 Input: 123 Output Conclusion A Strong Number is a number where the sum of the factorials of its digits is equal to the number itself. This Java program helps us check ...
number=number/10; } if(originalNumber==sum) { returntrue; } returnfalse; } } When you run above program, you will get following output. 1 2 3 4 5 Is153Armstrongnumber:true Is234Armstrongnumber:false Is371Armstrongnumber:true Please go throughFrequently asked java interview Programsfor more...
Java program to check whether a given number is ugly number or not importjava.util.Scanner;publicclassCheckUglyNumbers{publicstaticvoidmain(String[]args){// create object of scanner class.Scanner Sc=newScanner(System.in);// enter the positive numberSystem.out.print("Enter the number : ");int...
// Java program to check whether a class is declared // as an enum or not enum A { RED, GREEN, BLUE; } public class Main { public static void main(String[] args) throws ClassNotFoundException { Class cls1 = A.class; Class cls2 = Main.class; if (cls1.isEnum()) System.out...