# ZeeZee Bank Java Solution

## ZeeZee Bank Java Solution

Sample Input and Output 1:

``````Enter the account number:
9876543210
Enter initial balance:
15000
Enter the amount to be deposited:
1500
Available balance is:16500.00
Enter the amount to be withdrawn:
500
Available balance is:16000.00``````

Sample Input and Output 2:

``````Enter the account number:
9876543210
Enter initial balance:
15000
Enter the amount to be deposited:
1500
Available balance is:16500.00
Enter the amount to be withdrawn:
18500
Insufficient balance
Available balance is:16500.00``````

## SOLUTION

Program: ZeeZee Bank Java Solution Main.java

``````import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
DecimalFormat decimalFormat = new DecimalFormat("0.00");
System.out.println("Enter the account number:");
long accountNumber = scanner.nextLong();
System.out.println("Enter initial balance:");
double balanceAmount = scanner.nextDouble();
Account account = new Account(accountNumber, balanceAmount);
System.out.println("Enter the amount to be deposited:");
double depositAmount = scanner.nextDouble();
account.deposit(depositAmount);
double availableBalance = account.getBalanceAmount();
System.out.println("Available balance is:" + decimalFormat.format(availableBalance));
System.out.println("Enter the amount to be withdrawn:");
double withdrawAmount = scanner.nextDouble();
boolean isWithdrawn = account.withdraw(withdrawAmount);
availableBalance = account.getBalanceAmount();
if (!isWithdrawn) {
System.out.println("Insufficient balance");
}
System.out.println("Available balance is:" + decimalFormat.format(availableBalance));
}
}``````

Program: ZeeZee Bank Java Solution Account.java

``````public class Account {
private long accountNumber;
private double balanceAmount;
public Account(long accountNumber, double balanceAmount) {
this.accountNumber = accountNumber;
this.balanceAmount = balanceAmount;
}
public long getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(long accountNumber) {
this.accountNumber = accountNumber;
}
public double getBalanceAmount() {
return balanceAmount;
}
public void setBalanceAmount(double balanceAmount) {
this.balanceAmount = balanceAmount;
}
public void deposit(double depositAmount) {
balanceAmount += depositAmount;
}
public boolean withdraw(double withdrawAmount) {
if (withdrawAmount <= balanceAmount) {
balanceAmount -= withdrawAmount;
return true;
}
return false;
}
}``````

Related: