SWT301_-_SU_2024_-_PE1_2328.webp
H

SWT301_-_SU_2024_-_PE1_2328.webp

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)
The Fibonacci sequence is an infinite sequence of positive integers starting with two elements 0 and 1. Subsequent elements follow the rule: each element is always equal to the sum of the two preceding elements. For example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... The code below finds the
Fibonacci number sequence in Java.
1 import java.util.Scanner;
2
3 class Fibonacci {
4
5
6
7
8
9
public static void main(String args) {
int n;
System.out.print("Enter the number of first digits in "the fibonacci sequence you want to output: ");
try (Scanner scanner Scanner(System.in)) {
n = scanner.nextInt();
10 }
11
12
13
14
int n10; n2 = 1;
if (n == 1) {
System.out.print(n1);
} else if (n == 2) {
Close
+ 100%
Zoom
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
SWT301_-_SU_2024_-_PE1_2328.webp
File size
292.8 KB
Dimensions
1920px x 803px

Share this media

Back
Bên trên Bottom