Zoom
SWT301_FA25_PE1
Intructions:
• You need to know at least one programming language to perform reasonably well on
certain exam questions.

Students are not allowed to use IDEs such as NetBeans, IntelliJ IDEA, or similar software
to do the test.
.
• All the answers must be written in the provided template file, in Enghlish and reflect
this 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)
This program checks whether a given number is a Happy Number. It repeatedly replaces the
number with the sum of the squares of its digits until it either becomes 1 (happy) or enters a cycle
that never reaches 1 (unhappy). For example: 1912+92 = 8282 + 2² = 686² + 8² = 100
→ 12+0² + 0² = 1 → Happy.
1. class happyNumber {
2.
3.
4.
5.
F
public static void main(String[] args) {
Scanner sc Scanner(System.in);
System.out.print("Enter a number to check: ");
int num se nextInt().
+100%
Close