题目要求如下:
Write a program named bank that maintains a database of bank accounts. Each account will be stored in a BankAccount object. The Following example shows what the user will see:
commands:
-------------------------------------------------
| Commands: o - Open account c - Close account|
| d - Deposit w - Withdraw |
| s - Select account q - Quit |
-------------------------------------------------
Current account: None selected
Enter command: o
Enter new account number: 158-740
Enter initial balance: 250
-------------------------------------------------
|Commands: o - Open account c - Close account|
| d - Deposit w - Withdraw |
| s - Select account q - Quit |
-------------------------------------------------
Current account: 158-740 Balance: 250.00
Enter command:
The program repeatedly prompts the user to enter commands, which it then executes. The program will not terminate until the user enters the command q. Note that the list of commands is redisplayed after each command has been executed, along with the current access and its balance. If there is not current account, the message
None selected
is displayed instead of the account number.
Commands Documentation:
Open account: The user is prompted to enter a new account number and initial balance. This data is stored in a new BankAccount object. BankAccount objects for all the existing accounts must be stored in an array. The new account becomes the current account.
Close account: If there is no current account, the message
Please select an account
is displayed. Otherwise, the current account is closed. There is no current account after this operation is completed.
Deposit: If there is no current account, the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the deposit:
Enter amount to deposit: 100
The amount entered by the user is added to the balance of the current account.
Withdraw: If there is no current account the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the withdrawal
Enter amount to withdraw: 25
The amount entered by the user is subtracted to the balance of the current account.
Select account: The user is prompted to enter an account number
Enter account number: 158-740
The array is then searched to see if any BankAccount object contains this number. If, so, that object becomes the current account. If not, the following message is displayed
Account number was not found
Quit: Terminate program.
Few other requirements for the program:
The size of array used to store BankAccount objects must be 20 elements.
Add sufficient comments to your code.
Follow Java indentation rules.
不知道谁能帮忙给写下这个代码。。。也不知道该如何感谢,只能先用这里的金币来感谢了。
希望可以得到帮助。谢谢了先。
Write a program named bank that maintains a database of bank accounts. Each account will be stored in a BankAccount object. The Following example shows what the user will see:
commands:
-------------------------------------------------
| Commands: o - Open account c - Close account|
| d - Deposit w - Withdraw |
| s - Select account q - Quit |
-------------------------------------------------
Current account: None selected
Enter command: o
Enter new account number: 158-740
Enter initial balance: 250
-------------------------------------------------
|Commands: o - Open account c - Close account|
| d - Deposit w - Withdraw |
| s - Select account q - Quit |
-------------------------------------------------
Current account: 158-740 Balance: 250.00
Enter command:
The program repeatedly prompts the user to enter commands, which it then executes. The program will not terminate until the user enters the command q. Note that the list of commands is redisplayed after each command has been executed, along with the current access and its balance. If there is not current account, the message
None selected
is displayed instead of the account number.
Commands Documentation:
Open account: The user is prompted to enter a new account number and initial balance. This data is stored in a new BankAccount object. BankAccount objects for all the existing accounts must be stored in an array. The new account becomes the current account.
Close account: If there is no current account, the message
Please select an account
is displayed. Otherwise, the current account is closed. There is no current account after this operation is completed.
Deposit: If there is no current account, the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the deposit:
Enter amount to deposit: 100
The amount entered by the user is added to the balance of the current account.
Withdraw: If there is no current account the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the withdrawal
Enter amount to withdraw: 25
The amount entered by the user is subtracted to the balance of the current account.
Select account: The user is prompted to enter an account number
Enter account number: 158-740
The array is then searched to see if any BankAccount object contains this number. If, so, that object becomes the current account. If not, the following message is displayed
Account number was not found
Quit: Terminate program.
Few other requirements for the program:
The size of array used to store BankAccount objects must be 20 elements.
Add sufficient comments to your code.
Follow Java indentation rules.
不知道谁能帮忙给写下这个代码。。。也不知道该如何感谢,只能先用这里的金币来感谢了。
希望可以得到帮助。谢谢了先。

