SWT301_-_SP_2024_-_PE2_1721.webp
successful_man

SWT301_-_SP_2024_-_PE2_1721.webp

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)
1. import java.lang.*;
2. import java.io.*;
3.
4. class Primenumber {
5.public static void main(String args[]) {
6.
int temp,
7.
8.
9.
10.
11.
12.
13.
14.
15.
int n;
boolean isPrime=true;
Scanner scan new Scanner(System.in);
System.out.println("Enter the number to check:");
int num scan.nextInt();
for(int i 2; i< num/2; i++) {
temp = num%i;
if(temp == 0) {
isPrime false;
16.}
17.
break;
18.}
19.
20.
if(isPrime)
System.out.println(num" is not a prime number!");
21.else
22.
System.out.println(num" is a prime number!");
23.}
24. }
Zoom
+ 94%

Close
Chưa có bình luận nào.

Thông tin

Category
SWT301
Thêm bởi
successful_man
Ngày thêm
Lượt xem
3,116
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
SWT301_-_SP_2024_-_PE2_1721.webp
File size
216 KB
Dimensions
958px x 1000px

Share this media

Back
Bên trên Bottom