Fibonacci Number

Question Description

I have a Fibonacci number program in java and it works very well, I just want it to give me the following 50 Fibonacci numbers when I get my answer. How do I program it to do that? here's my code:

  import java.util.Scanner;

public class FibonacciNumber {

private static Scanner console;

/** * @param args */

 public static void main(String[] args) {

// TODO Auto-generated method stub


  int previous1;

int previous2;

  int current = 0;

  int counter;

  int nthFibonacci;

Object FubonacciNumber;

Scanner console = new Scanner(System.in);

  //Prompt the user for input

System.out.println("Enter the first Fibonacci number: ");

previous1 = console.nextInt();

System.out.println("Enter the second Fibonacci number: ");

previous2 = console.nextInt();

System.out.println("The first two numbers of the Fibonacci sequence are: " + previous1 + "and" + previous2);

System.out.println("Enter the position of the desired number in " + "the Fibonacci sequence: ");

  nthFibonacci = console.nextInt();

  if (nthFibonacci == 1) current = previous1;

else if (nthFibonacci == 2) current = previous2;

  else   { counter = 3;

while (counter <= nthFibonacci) {

current = previous2 + previous1; previous1 = previous2;

previous2 = current; counter++;

  } } System.out.println("\nThe " + nthFibonacci + "th Fibonacci number of " + "the sequence is: " + current); }

private static int nextInt(int counter) {

// TODO Auto-generated method stub return 0; } }

Final Answer

Thank you for the opportunity to help you with your question!

you can not ask such a long question in free zone 

I can do your assignment, Assignment will be fresh and original, that's my guarantee . If you want any sample work I can provide you . Waiting for positive reply . Thanks

Please let me know if you need any clarification. I'm always happy to answer your questions.

Harsh V (108)
Boston College

Thanks for the help.

Outstanding. Studypool always delivers quality work.

Tutor was very helpful and took the time to explain concepts to me. Very responsive, managed to get replies within the hour.


Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors