All the answers must be written in the provided template file, in Enghlish and reflect is exam paper. If your answers to the questions in this exam paper have any keywords not related to this electronic exam paper, the answers to the questions will get ZERO. If you do not use the provided template file to answer the exam you take today, your exam will get ZERO.
Question 1 (3 points): Review the following class and find (at least) 6 issues in the code (i.e,coding practice, compile errors, potential logical issue, etc.) (Use question 1 template)
An Armstrong number is a number that is equal to the sum of its digits each raised to the power of the number of digits. In other words, if you take each digit in the number, raise it to the power of the total count of digits in the number, and then sum them all together, the result is the original number itself. For example: 153 is an Armstrong number, 153=1*1*1+5*5*5+3*3*3. The code below checks the Armstrong number in Java.
1 import java.util.Scanner;
2
class Armstrong {
3
4
5
6
7
public static void main(String[] args) {
int number, originalNumber, result 0, n = 0;
System.out.print("Enter the number you need to check: ");
8
try (Scanner scanner new Scanner(System.in)) {
9
number = scanner.nextInt();
}
10
originalNumber = number;
11
for (;originalNumber != 0; originalNumber / 10, n);
12
originalNumber = number/10;
13
for (;originalNumber = 0; originalNumber /= 10)
14
{
15
remainder originalNumber * 10;
Zoom
100%
Close