...
/Solution Review: Design a Banking Application
Solution Review: Design a Banking Application
Have a look at the solution to the 'Design a Banking Application' challenge.
We'll cover the following...
Account
class
Rubric criteria
First, look at the Account
class.
Press + to interact
public class Account{// private instancesprivate String accNo;private double balance;// constructorpublic Account(String accNo, double balance){this.accNo = accNo;this.balance = balance;}// withdrawal methodpublic void withdrawal(double cash){if (cash != 0 && cash <= this.balance && cash <= 50000){balance -= cash; // Deducting balanceSystem.out.println("Withdrawal is successful. Your current balance is $" + balance);}else // error message{System.out.println("Please enter the correct amount.");}}// deposit methodpublic void deposit(double cash){if (cash != 0 && cash <= 100){balance += cash; // Updating balanceSystem.out.println("Deposit is successful. Your current balance is $" + balance);}else // error message{System.out.println("Please enter the correct amount.");}}}
Rubric-wise explanation
Point 1:
We create the header of the Account
class at line 1.
Point 2:
Initially, we create its private
instances: accNo
and balance
. Next, at line 8, we design its constructor.
Point 3:
Now look at line 15. We create the header of the withdrawal()
method. According to the problem statement, it takes an amount of double
type: cash
. We can only withdraw the money if cash
is not ...