0

可能重复:
尝试为银行应用程序调用名为 addAccount 的方法,但它一直给我 .class 是预期错误

我正在尝试为银行申请做学校作业。它应该有 addAccount 方法并从 2 个数组中获取 2 个参数;accountNumber 和 accountBalance 分别。我正在尝试将 accountNoArray 输入到 addAccount 方法中,但是当我这样做并调用它时,它说 .class 是预期错误

import java.util.*;
public class bank
{
public static void main(String[]args)
{
    Scanner sc = new Scanner(System.in);
    int choice = 0;
    int accountNo = 0;
    double accountBal = 0;
    int[] accountNoArray = new int[20];
    double[] accountBalArray = new double[20];
    displayMenu();
    System.out.print("Please Enter Your Choice: ");
    choice = sc.nextInt();
    switch(choice)
    {
        case 1 : addAccount(accountNo,accountBal,sc); break;
    }
}

public static void displayMenu()
{
    System.out.println("Menu");
    System.out.println("1. Add an account");
    System.out.println("2.Search an account with the given account number");
    System.out.println("3.Display accounts below the given balance");
    System.out.println("4.Exit");
}   

public static void addAccount(int accountNo,double accountBal,Scanner sc)
{
    System.out.print("Please Enter NRIC Number: ");
    accountNo = sc.nextInt();
    System.out.print("Please Enter Account Balance: ");
    accountBal = sc.nextInt();
}
}
4

0 回答 0