Minimum Balance Problem In Banking

In this video we will see a java code for Minimum Balance Problem In Banking. We will see an Step By step Algorithm to write a java code for making transactions in account with maintaining minimum balance.

Minimum Balance Problem In Banking

Your account balance is 25000.00 and minimum balance which you should maintain is 1500.00 and every time you can only withdraw 2000.00 from your account.

Write a java program to withdraw amount from account until balance becomes zero or reaches minimum level.

Algorithm For Solving Banking Problem

  • First Read the initial balance in account, here it is 25000.00
  • Next Set the minimum balance criterion for withdrawing amount from account. Here it is 1500.00
  • Then set how much we want to withraw each time, here it is 2000.00
  • Now check withdrwa amount is less than balanace or not
  • Next check if balance is greater after deducing aount from account balance, if true deduct the amount from account balance else pass message saying “Insufficient Balanace in account
  • Update the account balance.

JAVA Code for Baking Minimum Balance Problem

public class problem31 {
    public static void main(String[] args) {
        double accbal=25000.00;
        double amount=2000.00;
        double min=1500.00;

        while(accbal>min){

            if(amount<accbal){
                if(accbal-amount>min){
                    accbal=accbal-amount;
                    System.out.println("Your account balance is :"+ accbal );
                }
                else{
                    System.out.println("You can withdraw only Rs :" + min );
                    break;
                }
            }
            else{
                System.out.println("In-sufficient Balance !!!");
            }           
        }
        System.out.println("Your accout balance is :"+ accbal);
        System.out.println("program ended..........");
        
    }
    
}

Want More Explanation of Above Code Visit our channel Below

Leave a Comment

Your email address will not be published. Required fields are marked *