import java.util.Scanner;
public class PayAndGoParking
{
public static void main(String Args[])
{
int choice=0;
int numCars=0;
String Plates[]=new String[50];
String ccNumbers[]=new String[50];
Scanner b = new Scanner(System.in);
choice = printMenu();
if(choice==1) {
numCars=addCars(Plates,ccNumbers,numCars,b);
}
}
public static int printMenu()
{
Scanner s = new Scanner(System.in);
int choice;
System.out.println("Welcome to Park and Go Parking");
System.out.println("Park from 6 - Midnight for a flat fee of $4.00");
System.out.println("1. Register your vehicle");
System.out.println("2. Verify vehicle registration");
System.out.print("Hello enter a Selection: ");
choice = s.nextInt();
if(choice==1) {
System.out.println("Register your vehicle");
}
else {
System.out.println("Verify your registration");
}
return choice;
}
public static int addCars (String [] plates,String [ ] ccNumbers, int numCars, Scanner keyboard)
{
Scanner s = new Scanner(System.in);
System.out.println("Enter your plate number: ");
plates[numCars]=s.nextLine();
System.out.println("Enter your Credit Card Number ($4.00 charge): ");
ccNumbers[numCars]=s.nextLine();
System.out.println("Thank you, your plate " +plates[numCars]+ " has been added to the lot");
numCars++;
return numCars;
}
所以几乎我想要发生的事情是,我希望用户在 addCars 方法中输入的任何车牌号和 ccNumber 都存储在 main 方法中的车牌和 ccNumber 数组中。对不起,如果我听起来好像我不知道我在说什么,我对编程是全新的并且正在学习。