I need help creating a loop.The loop will ask the user for a number in the Fibonacci series. if the user enter 3... the program will print out 2 in the Fibonacci series, the program will keep asking the user to enter a new number unless the user enters 0. I keep getting an error in the method line." class, interface, enum". If I take out the " do while loop" the program works. I am thinking that the loop is stopping the method call, but I am not sure how to stop that.
Scanner i = new Scanner (System.in);
System.out.println("Given a number n, this program will return the N-th Fibonacci number in an interger type.\n");
do
{
int number = 0;
System.out.print ("Please input your number: ");
number = i.nextInt();
System.out.printf (" The %d-th is fibinocci number is %.0f\n",number, fibcalic(number));
}
while (number != 0);
}
} // end main method
public static int fibcalic(int number)// method
{
int max = number;
int[] fibarray = new int [max];// set the array to int max is still int
fibarray [0] = 0;
fibarray [1] = 1;
for (int a=2; a < max; a++)
{
fibarray[a] = fibarray[a -1] + fibarray[a -2];
}
return fibarray[number];
}