我在放置括号时遇到了一些麻烦。我想在我的主要方法范围内编写一些方法,但我总是以一堆红线和错误告终,告诉我“这一行有多个标记 - 令牌“void”上的语法错误,@预期 - addVehicleBooking无法解析为类型”
我不希望我的方法返回任何东西,我只想让它们执行一些代码并在屏幕上打印一些东西。
编辑:
这是代码的开始,无需担心未使用的变量等。感谢大家的帮助=]。
import java.util.Scanner;
public class FerryMenu {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Scanner scan = new Scanner(System.in);
public static void addVehicleBooking()
{
String booking_ID = "";
System.out.print("Enter your booking ID");
booking_ID = input.next();
String registration = "";
System.out.print("Enter registration number");
registration = input.next();
String make_model = "";
System.out.print("Enter vehicle make/model");
make_model = input.next();
int number_passengers = 1;
System.out.print("Enter number of passengers");
number_passengers = scan.nextInt();
}
String menu_choice = "";
while(!"X".equals(menu_choice)){
System.out.println("*** Ferry Ticketing System Menu ***");
System.out.println("A - Add Vehicle Booking");
System.out.println("B - Display Booking Info");
System.out.println("C - Update Insurance Status");
System.out.println("D - Display Booking Summary");
System.out.println("X - Exit");
System.out.print("Enter your selection: ");
menu_choice = input.next();
}
}
}