My code is very basic as I started Java this week. However, I cannot seem to get my else if statements working. Here is my code:
import java.util.Scanner;
class RestaurantMain {
public static void main(String[] args)
{
//Variables//
int choice;
//EndVariables//
Scanner in = new Scanner(System.in);
System.out.println("Welcome to the Cooper's restaurant system!");
System.out.println("How can I help?");
System.out.println("");
System.out.println("1. Customer System");
System.out.println("2. Management System");
System.out.println("");
System.out.println("");
System.out.println("Which option do you choose: ");
choice = in.nextInt();
if (choice == 1); {
System.out.println("You have entered the customer system!");
}
else if (choice == 2); {
System.out.println("You have entered the management system!");
}
}
}
This is the error I am getting:
RestaurantMain.java:26: error: 'else' without 'if'
else if (choice == 2); {
^
1 error
Tool completed with exit code 1
I have no idea what to do. I am using TextPad and I have had my else if statements (not these ones specifically) work in another file.
Thanks for helping if you can!
Aucun commentaire:
Enregistrer un commentaire