import java.util.Scanner; class Balance { Scanner sc=new Scanner(System.in); int bal; void balc() { System.out.println("\n Enter the Amount : "); bal=sc.nextInt(); } } class Withdraw extends Balance { int amtw; void wtdrw() { balc(); System.out.println("\n Enter the amount to withdraw : "); amtw=sc.nextInt(); if(bal>amtw) { amtw=bal-amtw; } else { System.out.println("\n Cannot Withdraw "); } } } class B extends Withdraw { public static void main(String[] args) { int i; Scanner sc= new Scanner (System.in); String desg; String s1="balance"; String s2="withdraw"; System.out.println("\n Banking process "); Withdraw[] obj = new Withdraw[4]; for(i=1;i<3;i++) { System.out.println("\n Enter the process : "); desg=sc.nextLine(); if(desg.equals(s1)) { obj[i]=new Withdraw(); obj[i].balc(); } else if(desg.equals(s2)) { obj[i]= new Withdraw(); obj[i].wtdrw(); } } } }