阅读背景:

如何在一个方法中从数组中获取值列表,并将这些值从我的main方法放入一个新数组中

来源:互联网 
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 .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 (.00 charge): ");
        ccNumbers[numCars]=s.nextLine();



        System.out.println("Thank you, your plate " +plates[numCars]+ " has been added to the lot");

        numCars++;


        return numCars;



    }
import java.util.Scanner;

public class PayAndG



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: