Implement a Java program to check if a number is Armstrong or not.

Here’s a Java program to check if a number is Armstrong or not:

import java.util.Scanner;

public class ArmstrongNumber {
    public static void main(String[] args) {
        int num, originalNum, remainder, result = 0;
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a number: ");
        num = scanner.nextInt();
        originalNum = num;
        while (originalNum != 0) {
            remainder = originalNum % 10;
            result += Math.pow(remainder, 3);
            originalNum /= 10;
        }
        if (result == num) {
            System.out.println(num + " is an Armstrong number.");
        } else {
            System.out.println(num + " is not an Armstrong number.");
        }
    }
}

In this program, we first take user input for a number. We then use a while loop to iterate over each digit of the number and calculate its cube. We add the cubes of all the digits to a variable `result`. We then compare `result` with the original number. If they are equal, then the number is an Armstrong number.

An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.

At the end of the program, we print out whether the number is an Armstrong number or not.