/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Jawokong;
import java.util.Arrays.*;
import java.io.*;
public class MyBankObject
{
public static void main(String args[])throws IOException
{
int cid2=0 ,cid3=0,cid4=0;
double a, ia =0;
String ln, fn ="";
int count =0,count2 = 0, count3 =0, count4 =0, index = 5, idnos=1005;
int found =0;
boolean bk =true, stop = true;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
MyBank OpenBank = new MyBank();
OpenBank.setBankName("Banco De Jairoh");
OpenBank.setBankAddress("Dumaguete City");
OpenBank.setMaxCustomer(1000);
OpenBank.addCustomer(0,1000,"Nash","Steve",10000);
OpenBank.addCustomer(1,1001,"Parker","Tony",11000) ;
OpenBank.addCustomer(2,1002,"Nowtitzki","Dirk",120 00);
OpenBank.addCustomer(3,1003,"Anthony","Carmelo",13 000);
OpenBank.addCustomer(4,1004,"Allen","Rey",14000);
OpenBank.addCustomer(5,1005,"James","Lebron",15000 );
do{
System.out.println("[1]Create Account \n[2]Deposit \n[3]Withdraw \n[4]CheckBalance \n[5]Exit");
System.out.println("CHOOSE ALTERNATIVES");
int choose = Integer.parseInt(br.readLine());
System.out.println("");
switch(choose)
{
case 1:
System.out.println("CREATE AN ACCOUNT");
System.out.print("Last Name: ");
ln = br.readLine();
System.out.print("");
System.out.print("First Name: ");
fn = br.readLine();
System.out.print("");
do{
System.out.print("Initial Amount: ");
ia = Double.parseDouble(br.readLine());
if(ia<500)System.out.println("Initial Amount must not be less than 500$");
}while(ia<500);
index +=1;
idnos +=1;
OpenBank.addCustomer(index, idnos, fn, ln, ia);
System.out.print("");
System.out.println("Thankyou for trusting "
+OpenBank.getBankName()+ "\nYour Customer ID is "+idnos+"\nYour Balance is $"+OpenBank.getBalance(index));
break;
case 2:
System.out.println("DEPOSIT");
do{
System.out.print("Customer ID: ");
cid2 = Integer.parseInt(br.readLine());
if(cid2<1000||cid2>idnos)System.out.println("Inval id ID. Try Again.");
}while(cid2<1000||cid2>idnos);
for(;count2<OpenBank.customerID.length;count2++)
{
if(cid2==OpenBank.customerID[count2])
{
break;
}
}
System.out.println("");
System.out.println(OpenBank.customerLastName[count2]+" "+OpenBank.customerFirstName[count2]);
System.out.println("Current Balance: $"+OpenBank.getBalance(count2));
do{
System.out.print("Amount: ");
a = Double.parseDouble(br.readLine());
if(a<100)System.out.println("Amount to deposit must not be less than $100");
}while(a<100);
OpenBank.setDepositAmount(count2,a);
System.out.println("New Balance: $"+OpenBank.getBalance(count2));
break;
case 3:
System.out.println("WITHDRAW");
do{
System.out.print("Customer ID: ");
cid3 = Integer.parseInt(br.readLine());
if(cid3<1000||cid3>idnos)System.out.println("Inval id ID. Try Again.");
}while(cid3<1000||cid3>idnos);
for(;count3<OpenBank.customerID.length;count3++)
{
if(cid3==OpenBank.customerID[count3])
{
break;
}
}
System.out.println("");
System.out.println(OpenBank.customerLastName[count3]+" "+OpenBank.customerFirstName[count3]);
System.out.println("Current Balance: $"+OpenBank.getBalance(count3));
do{
System.out.print("Amount: ");
a = Double.parseDouble(br.readLine());
if(a>OpenBank.getBalance(count3))System.out.printl n("Insufficient Balance. Please try again.");
}while(a>OpenBank.getBalance(count3));
OpenBank.setWithdrawAmount(count3,a);
System.out.println("New Balance: $"+OpenBank.getBalance(count3));
break;
case 4:
System.out.println("CHECK BALANCE");
do{
System.out.print("Customer ID: ");
cid4 = Integer.parseInt(br.readLine());
if(cid4<1000||cid4>idnos)System.out.println("Inval id ID. Try Again.");
}while(cid4<1000||cid4>idnos);
for(;count4<OpenBank.customerID.length;count4++)
{
//do{
if(cid4==OpenBank.customerID[count4])
{
stop = false;
break;
}
stop = true;
//count4++;
//}while(stop);
}
System.out.println("");
System.out.println(OpenBank.customerLastName[count4]+" "+OpenBank.customerFirstName[count4]);
System.out.println("Balance: $"+OpenBank.getBalance(count4));
break;
case 5:
System.exit(0);
break;
default:
System.out.println("Invalid Input");
break;
}
System.out.println("");
}while(bk);
}
}