如何在运行存款方法中询问用户帐号和存款金额

时间:2016-07-25 20:19:08

标签: java methods menu

如何在运行存款方式中询问用户帐号和存款金额。这是解决这个问题的最佳方法吗?我不太确定如何在java中做一个菜单,并试图适应一些我已经看过的。

感谢任何帮助/建议

欢呼

package Week8;

import java.util.ArrayList;
import java.util.Scanner;

public class BankTester {

    public static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {

        Customer customer1 = new Customer("Jim", "Brown", "12/1265");

        CurrentAccount currentAccount1 = new CurrentAccount(0.0, customer1, AccountType.personal, 25.0);

        ArrayList<CurrentAccount> bank = new ArrayList<CurrentAccount>();
        bank.add(currentAccount1);

        printMenu(bank);

    }

    private static void printMenu(ArrayList<CurrentAccount> bank) {
        System.out.println("\n1)Deposit\n2)Withdraw\n2)Month End\n3)Quit");
        System.out.println("Please Select and an Option: ");







        int input = in.nextInt();
        in.nextLine();
        int currentAccountPos = -1;
        switch (input) {
        case (1):
            Deposit(currentAccountPos, bank);
            break;

        case (2):
            Withdraw(currentAccountPos, bank);
            break;

        case (3):
            MonthEnd(currentAccountPos, bank);
            break;

        case (0):
            Quit(currentAccountPos, bank);
            break;

        }

    }

    private static void Quit(int currentAccountPos, ArrayList<CurrentAccount> bank) {
        System.exit(0);

    }

    private static void Withdraw(int currentAccountPos, ArrayList<CurrentAccount> bank) {
        // TODO Auto-generated method stub

    }

    private static void MonthEnd(int currentAccountPos, ArrayList<CurrentAccount> bank) {
        // TODO Auto-generated method stub

    }

    public static void Deposit(int currentAccountPos, ArrayList<CurrentAccount> bank) // this method here {

        }
} 

1 个答案:

答案 0 :(得分:0)

在案例(1)中试试这个。

$('#formId').on('change', 'input,textarea,select', function(){
 var element = $(this), // element that changed
     value = element.val(); // its new value
 // do what you want ..
});