import javax.swing.JOptionPane; import java.util.*; /* Written By : Ahmad Jawed ZAFAR Date : 01/02/2009 */ public class Bank { public static void main(String[] args) { String perId, moneyAmount, depositTemp, password; int select=0, count=0, id=0; double TotalDeposit=0; String option; String[] names = new String[20]; String[] surnames = new String[20]; int[] accountNo = new int[20]; double[] deposits = new double[20]; Random rand = new Random(); while (select != 6) { try { option = JOptionPane.showInputDialog("Please Select An Operation.\n" + "********************************\n" + "Enter '1' Admin\n" + "Enter '2' For Depositing Money\n" + "Enter '3' For Money Takeout\n" + "Enter '4' For Account Information\n" + "Enter '5' For Transfering Money\n" + "Enter '6' To Exit"); select = Integer.parseInt(option); if (select == 6)// condition for exit { JOptionPane.showMessageDialog(null, "******** Good Bye ********"); System.exit(0); } else if (select == 2) // condition for depositing money { double amount=0; int check=0, i=0; perId = JOptionPane.showInputDialog("Enter Your Account Number"); id = Integer.parseInt(perId); for (i=0; i 0) { moneyAmount = JOptionPane.showInputDialog("Enter The Money Amount"); amount = Integer.parseInt(moneyAmount); deposits[i] = deposits[i] + amount; // adds to customer deposit TotalDeposit = TotalDeposit + amount; // adds to Total bank Deposit JOptionPane.showMessageDialog(null, "You Have Deposited $ " +amount + " Successfully"); } else // check for account number in depositing money { JOptionPane.showMessageDialog(null, "Invalid Account Number !"); } }// end of depositing money else if (select == 3) // condition for money takeout { double amount3=0; int check3=0, i3=0; perId = JOptionPane.showInputDialog("Enter Your Account Number"); id = Integer.parseInt(perId); for (i3=0; i3 0) { moneyAmount = JOptionPane.showInputDialog("Enter The Money Amount"); amount3 = Integer.parseInt(moneyAmount); if (amount3 > deposits[i3]) { JOptionPane.showMessageDialog(null, "Sory ! You Dont Have Enough Deposit"); } else { deposits[i3] = deposits[i3] - amount3; TotalDeposit = TotalDeposit - amount3; JOptionPane.showMessageDialog(null, "You Have Taken Out $ " +amount3 + " Dollars"); } } else { JOptionPane.showMessageDialog(null, "Invalid Account Number !"); } } // end of money takeout else if (select == 4) // account information { int count4=0; int Id4=0; perId = JOptionPane.showInputDialog("Enter Your Account Number"); Id4 = Integer.parseInt(perId); for (int j=0; j 0)// checks for customer id { transferID = JOptionPane.showInputDialog("Enter The Account Number You" + " Want To Transfer Money"); transId = Integer.parseInt(transferID); for (ii=0; ii 0) // checks for other id { moneyAmount = JOptionPane.showInputDialog("Enter The Money" + " Amount You Want To Transfer"); amount5 = Integer.parseInt(moneyAmount); if (amount5 > deposits[i5]) // checks if there is enought moeny to transfer { JOptionPane.showMessageDialog(null, "You Dont Have" + " Enough Money To Transfer"); } else // performing transfer { deposits[ii] = deposits[ii] + amount5; // transfers money deposits[i5] = deposits[i5] - amount5; // cuts back money JOptionPane.showMessageDialog(null, "Money Has Been" + " Transfered Successfully\nAmount : " +amount5); } } else { JOptionPane.showMessageDialog(null,"Invalid Account Number"); } } else // check for account number in transfering money { JOptionPane.showMessageDialog(null, "Invalid Account Number !"); } }// end of money transfer else { JOptionPane.showMessageDialog(null,"Invalid Selection"); //System.exit(0); } } catch(NumberFormatException n) { JOptionPane.showMessageDialog(null,"Enter Numbers Only !","Error",JOptionPane.ERROR_MESSAGE); } }// end of First While }// end of methode main }//end of class Bank