Java: Please write code in Java 1. Ask for the name, account number, and initial balance for one account from the keyboa
Posted: Fri Jul 01, 2022 5:35 am
Java: Please write code in Java
1. Ask for the name, account number, and initial balance for oneaccount from the keyboard input. Create a CheckingAccount objectand initialize it using the constructor and the keyboard inputvalues on name, account number, and initial balance. Call thedisplayAccount() method to print the summary of this account.
2. Create a while loop to allow one to repeat the accountoperations as many as times as they want and choose the operationsthey want to perform: deposit, withdraw, or exit. i. If the choice isdepositing, ask the user to input the deposit amount from keyboard,then deposit it into the account you created by calling the depositmethod of the CheckingAccount object you have created. Call thedisplayAccount() method to print the summary of this account. ii. If the choice iswithdrawing, ask the user to input the withdraw amount fromkeyboard, then try to withdraw that amount from the account object.If the operation is successful, call the displayAccount() method toprint the summary of this account. Otherwise print the errorinformation that the withdrawing operation failed. iii. If the choice is exit, call thedisplayAccount() method to print the summary of this account andexit the program.
Test cases:Input initial balance of $100 for a checking account.
(1) Choose to deposit $-50, it should print out an error messageabout the deposit amountis negative.(2) Choose to deposit $ 200, it should display the new balancebeing $300.(3) Choose to withdraw $ 400, it should print out an error messageabout failedwithdrawing and display the new balance being $300 still.(4) Choose to withdraw $ 250, it should display the new balancebeing $50.(5) Choose to exit the program, it should display the new balancebeing $50 and theprogram stopped.
1. Ask for the name, account number, and initial balance for oneaccount from the keyboard input. Create a CheckingAccount objectand initialize it using the constructor and the keyboard inputvalues on name, account number, and initial balance. Call thedisplayAccount() method to print the summary of this account.
2. Create a while loop to allow one to repeat the accountoperations as many as times as they want and choose the operationsthey want to perform: deposit, withdraw, or exit. i. If the choice isdepositing, ask the user to input the deposit amount from keyboard,then deposit it into the account you created by calling the depositmethod of the CheckingAccount object you have created. Call thedisplayAccount() method to print the summary of this account. ii. If the choice iswithdrawing, ask the user to input the withdraw amount fromkeyboard, then try to withdraw that amount from the account object.If the operation is successful, call the displayAccount() method toprint the summary of this account. Otherwise print the errorinformation that the withdrawing operation failed. iii. If the choice is exit, call thedisplayAccount() method to print the summary of this account andexit the program.
Test cases:Input initial balance of $100 for a checking account.
(1) Choose to deposit $-50, it should print out an error messageabout the deposit amountis negative.(2) Choose to deposit $ 200, it should display the new balancebeing $300.(3) Choose to withdraw $ 400, it should print out an error messageabout failedwithdrawing and display the new balance being $300 still.(4) Choose to withdraw $ 250, it should display the new balancebeing $50.(5) Choose to exit the program, it should display the new balancebeing $50 and theprogram stopped.