Hello everyone, newbie here, im getting an "illegal start of expression" where the while loop starts but im not sure whats wrong with it. I would really appreciate it if anyone could help me as i understand most of the concepts of java but have a hard time writing the code for it.
The object of this program is for the user to select an operation of the 4 choices available to figure out fibonacci
Thank you in advance for your help!
import java.util.Scanner;
public class Fibonacci
{
public static void main(String[] args)
{
String operationS;
char operation;
Scanner scan = new Scanner( System.in );
//Welcome Message
System.out.println( " Welcome to the Fibonacci Calculator" );
while (operationS != 'q') && (operationS != 'Q');
{
//prints a menu, then prompts for the operation
System.out.println
(
"\nOperations are: "
+ "\n\t A for Recursive method that calculates Fibonacci numbers"
+ "\n\t B for Recursive method that reads an integer"
+ "\n\t C for Recursive method that prints the first N even numbers"
+ "\n\t D for Recursive method that adds the first N numbers"
+ "\n\t Q to Quit"
);
System.out.println( "Enter your selection: ");
operationS = scan.next( );
operation = operationS.charAt( 0 );
//perform the operation and print result
switch (operation)
{
case 'A':
case 'a':
System.out.println("\n\t Enter an integer between 5 and 20: ");
case 'B':
case 'b':
System.out.println("\n\t Enter an integer greater than 20: ");
case 'C':
case 'c':
System.out.println("\n\t Enter an integer: ");
case 'D':
case 'd':
System.out.println("\n\t Enter an integer: ");
case 'Q':
case 'q':
System.out.println("\n\t Exit: ");
}
}
}
public static int fibo (int n)
{
if (n<=1) //base case
return 1;
else
return fibo(n-1) + fibo(n-2); //general case
}
}