Question
This programs asks the user to enter a number n (bigger than 2). It then prints out the first n numbers of the Fibonacci Sequence.
This programs asks the user to enter a number "n" (bigger than 2). It then prints out the first "n" numbers of the Fibonacci Sequence. Each number is the sum of the two previous numbers.
Example: The output for n=11 should look exactly like this: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
Fix all compile-time and run-time errors.
import java.util.ArrayList; import java.util.List; import java.util.Scanner;
public class FibonacciBuggy { private static Scanner scanner;
public static void main(String[] args) { scanner = new Scanner(System.in); int n = 11; while (n > 2) { System.out.println("Enter a number bigger than 2: "); n = scanner.nextInt(); } printList(getFiboList(n)); }
private static List
private static void printList(List
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started