Professional Documents
Culture Documents
*;
public class Banking
/*
Debugger :
1. click on the line where u want to statrt to Debug(click in the grey portion).
2. Execute the prog. as u would do in terminal window
3. give the input. press enter.
4. Debugger window appears . open ur source code & the window
simultaneously.
5. Click "Step into" to view execution!
*/
{
public static void main (String args[])
{
Scanner in = new Scanner(System.in);
String nme[] = new String [5];
String ac[] = new String[5];
String adr[] = new String [5];
int p[] = new int[5];
double b[] = new double [5];
int i;
System.out.println("Enter Names, Account Nos., Addresses,Phone nos.,
Balances");
for(i = 0; i<5; i++)
{
nme[i] = in.nextLine();
ac[i] = in.nextLine();
adr[i] = in.nextLine();
p[i] = in.nextInt();
b[i] = in.nextDouble();
}
int ch, c, ph=0, mp = 0, t = 0;
double bl, amt, amt1, amt2, si;
String an, ad, n, man, da, d, w, be, ic;
boolean b1 = false, b2 = false, b3 = false, b4 = false, b5 = false, b6 =
false;
System.out.println("\t\t\t\t\t\t\t\tWelcome To Bharat Bank!!!!!!!");
System.out.println("\t\t\t\t\t\t\t\tPlease choose an option from those given
below:");
System.out.println("1. Accounts");
System.out.println("2. Deposit");
System.out.println("3. Withdraw");
System.out.println("4. Balance Enquiry");
System.out.println("5. Interest Calculation");
System.out.println("6. Exit");
System.out.println("\nPlease enter your choice:");
ch = in.nextInt();
switch(ch)
{
case 1:
System.out.println("1. Add a new account");
System.out.println("2. Modify an existing account");
System.out.println("3. Delete an account");
System.out.println("4. Exit");
System.out.println("Enter your choice:");
c = in.nextInt();
switch(c)
{
case 1:
/*You cannot increase the length of an array once it is declared.
The same problem follows in the subsequent lines too .
Because of the Systax error your program will not compile!
You must either write an[<index>] = an ; to add an element .But you
can never increase length
of an array once it is declared*/
if(man.equals(ac[i]))
{
b1 = true;
System.out.println("Enter new phone no.");
mp = in.nextInt();
p[i] = mp;
}
}
if (b1==false)
System.out.println("Sorry, No Match Found!!!");
break;
case 3:
System.out.println("Enter your Account Number:");
da = in.nextLine();
for(i=0; i<ac.length(); i++)
{
if(da.equals(ac[i]))
{
b2 = true;
nme[i] = "Account is deleted";
b[i] = 0;
}
}
if (b2==false)
System.out.println("Sorry, No Match Found!!!");
break;
case 4:
System.exit(1);;
break;
default:
System.out.println("Wrong choice!!");
}
break;
case 2:
System.out.println("Enter account no.");
d = in.nextLine();
for(i = 0; i<ac.length(); i++)
{
if(d.equals(ac[i]))
{
b3 = true;
System.out.println("Enter amount to be deposited:");
amt = in.nextDouble();
b[i]+=amt;
System.out.println("Your amount is deposited and your balance is
Rs."+b[i]);
}
}
if(b3 == false)
System.out.println("Sorry, no match found");
break;
case 3:
System.out.println("Enter account no.:");
w = in.nextLine();
for(i = 0; i<ac.length(); i++)
{
if(w.equals(ac[i]))
{
b4 = true;
System.out.println("Enter amount to be withdrawn:");
amt1 = in.nextDouble();
b[i]-=amt1;
System.out.println("Your amount is withdrawn and your balance is
Rs."+b[i]);
}
}
if(b4 == false)
System.out.println("Sorry, no match found");
break;
case 4:
System.out.println("Enter account no.:");
be = in.nextLine();
for(i = 0; i<ac.length(); i++)
{
if(be.equals(ac[i]))
{
b5 = true;
System.out.println("Your balance is Rs."+b[i]);
}
}
if(b5 == false)
System.out.println("Sorry, no match found");
break;
case 5:
System.out.println("Enter account no.:");
ic = in.nextLine();