Fixed 15 Java Programs With Output
Fixed 15 Java Programs With Output
This document contains 15 Java programs along with their outputs. Each program is detailed on a
separate page for better readability. The programs cover various basic and intermediate concepts of
Java programming.
Check Armstrong Number
Code:
import java.util.Scanner;
while (original != 0) {
original /= 10;
digits++;
}
original = num;
while (original != 0) {
int remainder = original % 10;
result += Math.pow(remainder, digits);
original /= 10;
}
if (result == num) {
System.out.println(num + " is an Armstrong number");
} else {
System.out.println(num + " is not an Armstrong number");
}
}
}
Output:
Enter a number: 153
153 is an Armstrong number
Print ASCII Value of a Character
Code:
import java.util.Scanner;
Output:
Enter a character: A
ASCII value of A is 65