Vous êtes sur la page 1sur 4

import java.util.

Scanner;
abstract class rbi
{
String name;
String phone;
long balance;

void getdetails()
{
System.out.println("");
Scanner scan = new Scanner(System.in);
System.out.println("Enter Name Of bank Customer");
name = scan.nextLine();
System.out.println("Enter Phone Of bank Customer");
phone = scan.nextLine();
System.out.println("Enter Balance Of bank Customer");
balance = scan.nextInt();
}

void dispname(int s)
{
System.out.println("Current Accounts in Bank:");
System.out.println((s+1) +". "+name);
}

void deposit()
{
System.out.println("");
Scanner scan = new Scanner(System.in);
long depo;
System.out.print("Enter Amount To Deposit: ");
depo=scan.nextInt();
balance+=depo;
System.out.println("Updated balance = "+balance);
}

void withdraw()
{
System.out.println("");
System.out.println("Current Balance = " + balance);
System.out.print("Enter Amount To Withdraw ");
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
if(x>balance)
{
System.out.println("Not Enough Balance");
}
else
{
balance = balance - x;
}
System.out.println("Updated balance = "+balance);
}
}

class Axis extends rbi {


static int number = 0;
Axis()
{
number++;
getdetails();
}
}

class Sbi extends rbi {


static int number = 0;
Sbi()
{
number++;
getdetails();
}
}

class cust
{
static void disp()
{
System.out.println("");
System.out.println("Choose Bank:");
System.out.println("1.SBI");
System.out.println("2.Axis");
}

public static void main(String[] args)


{

Scanner scan=new Scanner(System.in);


int sbc=0;
int axc=0;
int ac_c;
int choice=0,imc=0;
Sbi[] acc_sbi=new Sbi[10];
Axis[] acc_axis=new Axis[10];

while(choice!=4)
{
System.out.println("");
System.out.println("1. New Account");
System.out.println("2. Deposit");
System.out.println("3. Withdraw");
System.out.println("4. Exit");

choice=scan.nextInt();

switch(choice)
{
case 1: disp();
imc=scan.nextInt();
switch (imc)
{
case 1: acc_sbi[sbc]=new Sbi();
sbc++;
break;

case 2: acc_axis[axc]=new Axis();


axc++;
break;
}
break;

case 2: disp();
imc=scan.nextInt();
switch (imc)
{
case 1: if(sbc==0)
{
System.out.println("No Accounts");
break;
}
for(int i=0;i<sbc;i++)
{
acc_sbi[i].dispname(i);
}
ac_c=scan.nextInt();
acc_sbi[ac_c-1].deposit();
break;

case 2: if(axc==0)
{
System.out.println("No Accounts");
break;
}
for(int i=0;i<axc;i++)
{
acc_axis[i].dispname(i);
}
ac_c=scan.nextInt();
acc_axis[ac_c-1].deposit();
break;
}
break;

case 3: disp();
imc=scan.nextInt();
switch (imc)
{
case 1: if(sbc==0)
{
System.out.println("No Accounts");
break;
}
for(int i=0;i<sbc;i++)
{
acc_sbi[i].dispname(i);
}
ac_c=scan.nextInt();
acc_sbi[ac_c-1].withdraw();
break;

case 2: if(axc==0)
{
System.out.println("No Accounts");
break;
}
for(int i=0;i<axc;i++)
{
acc_axis[i].dispname(i);
}
ac_c=scan.nextInt();
acc_axis[ac_c-1].withdraw();
break;
}
break;

case 4: break;

default: System.out.println("Enter correct choice");


}
System.out.println("");
System.out.print("Total acc in ICICI: "+Sbi.number+"\n");
System.out.print("Total acc in Axis: "+Axis.number+"\n");
}
}
}