NabeelSHAIKH

Banking Application1

Sep 17th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.93 KB | None | 0 0
  1. import java.io.DataInputStream;
  2. import java.util.Scanner;
  3. import java.util.*;
  4. import java.io.PrintStream.*;
  5. /*class BankOperations performs all The operation required for Banking
  6.  class BankOperations is inherited from class Info*/
  7. class BankOperations extends Info
  8. {   /*Stores the Minimum balance i.e 500 default  ( final double) */   
  9.     final double minBal = 500;
  10.     int accNoGen;
  11.     public int total_acc = 0;
  12.     public Vector record = new Vector ( ) ;
  13.     BankOperations ( )
  14.     {
  15.         pw = "";
  16.         bal = "";
  17.         current = "Current";
  18.         savings = "Saving";
  19.     }
  20.     /*method newEntry : this method adds a new Entry ( Account in the list )*/
  21.     void newEntry ( )
  22.     {
  23.         double temp;
  24.         boolean valid = false;
  25.         int type;
  26.         record = new Vector ( );
  27.         System.out.println ( "\n************************************************" );
  28.         System.out.println ( "Enter Your Account Details" );
  29.         try
  30.         {
  31.             Scanner src = new Scanner ( System.in );
  32.             System.out.print ( "Enter Name : " );
  33.             accName.add ( src.nextLine (  ) );
  34.             System.out.print ( "Enter a 6 digit Account Number Of Your Choice : " );
  35.             accNoGen = src.nextInt (  );
  36.             if (  (  ( accNoGen / 100000 ) < 1.0 ) ||  (  ( accNoGen / 100000 ) > 9 ) )
  37.             {
  38.                 System.out.println ( "Invalid Account Number\nAccount Number Is Not 6 Digit Number" );
  39.                 accName.remove ( accName.size (  ) - 1 );
  40.                 newEntry ( );
  41.                 return;
  42.             }
  43.             if ( total_acc != 0 )
  44.                 valid = validator ( accNoGen );
  45.             if ( valid == true  )
  46.             {
  47.                 System.out.println ( "\nSorry, This Account Number Already Exist, Try Another One" );
  48.                 accName.remove ( accName.size (  ) - 1 );
  49.                 newEntry ( );
  50.             }
  51.             else
  52.             {
  53.                 accNo.add ( accNoGen );
  54.                 System.out.print ( "Please See That No one Is Beside You While Entering The New Password !!!!!\nEnter New Password : " );
  55.                 pw=src.next ( );
  56.                 accPword.add ( pw );
  57.                 System.out.println ( "Account Type : " );
  58.                 System.out.println ( "\t1.Current\n\t2.Savings" );
  59.                 System.out.print ( "Enter your account Type : " );
  60.                 type = 0;
  61.                 do
  62.                 {
  63.                     type = src.nextInt ( );
  64.                     if ( type == 1 )
  65.                     {
  66.                         accType.add ( current );
  67.                         break;
  68.                     }
  69.                     else if ( type == 2 )
  70.                     {
  71.                         accType.add ( savings );
  72.                         break;
  73.                     }
  74.                     else
  75.                     {
  76.                         System.out.println ( "Invalid Account Type. Try Again" );
  77.                         type = 0;
  78.                     }
  79.                 }while ( type == 0 );
  80.                 do
  81.                 {
  82.                     System.out.print ( "-Enter Initial  Amount to be deposited : " );
  83.                     temp = src.nextDouble (  );
  84.                     System.out.print ( "Enter The Amount to be deposited Again : " );
  85.                     bal = src.next ( );
  86.                     if ( temp < minBal )
  87.                         System.out.println ( "----------Enter Initial  Amount must be more or equal to Rs.500 " );
  88.                     else
  89.                     {
  90.                         accBal.add ( temp );
  91.                         record.add ( temp );
  92.                         balRecord.add ( record );
  93.                     }
  94.                 }while ( temp < minBal );
  95.                 total_acc++;
  96.                 clear ( );
  97.                 System.out.println ( "\nAccount Created Successfuly" );
  98.                 System.out.println ( "************************************************" );
  99.                 System.out.println ( "\n" );
  100.             }
  101.         }catch ( Exception e )
  102.         {
  103.             errorDisplay ( e );
  104.         }
  105.     }
  106.     /*This Method Display the details of Account */
  107.     void Display ( ){
  108.         boolean valid;
  109.         System.out.println ( "\n************************************************" );
  110.         System.out.println ( "=====DISPLAYING DETAILS OF CUSTOMER=====\n" );
  111.         try
  112.         {
  113.             Scanner src = new Scanner ( System.in );
  114.             System.out.print ( "Enter Your Account Number : " );
  115.             int accNoInput = src.nextInt (  );
  116.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  117.             System.out.print ( "Enter Your Password : " );
  118.             String pw = src.next (  );
  119.             clear ( );
  120.             valid = validator ( accNoInput );
  121.             if ( valid == true )
  122.             {
  123.                 int index = accNo.indexOf ( accNoInput );
  124.                 boolean validp = validatorP ( pw,index );
  125.                 if ( validp == true )
  126.                 {
  127.                     System.out.println ( "Account Number : " + accNo.get ( index ) );
  128.                     System.out.println ( "Account Name : " + accName.get ( index ) );
  129.                     System.out.printf ( "Account Balance: %.2f\n",+accBal.get ( index ) );
  130.                     System.out.println ( "Account Balance In Words : " );
  131.                     displayword (  ( int )Math.round ( accBal.get ( index ) ) );
  132.                     System.out.print ( " Rs " );
  133.                     int n = num ( bal );
  134.                     if ( n != 0 )
  135.                     {
  136.                         displayword ( n );
  137.                         System.out.println ( "Paise " );
  138.                     }
  139.                     System.out.println ( "\nAccount Type : " + accType.get ( index ) );
  140.                     if ( accType.get ( index ) == "Current" )
  141.                         System.out.println ( "Cheque Facility : Yes" );
  142.                     else
  143.                         System.out.println ( "Cheque Facility : No" );
  144.                 }
  145.                 else
  146.                     System.out.println ( "\nIncorrect Password" );
  147.             }
  148.             else
  149.                 System.out.println ( "\nInvalid Account Number\n" );
  150.             System.out.println ( "\n************************************************" );
  151.             System.out.println ( "\n" );
  152.         }catch ( Exception e )
  153.         {
  154.             System.out.println ( e );
  155.             errorDisplay ( e );
  156.         }
  157.     }
  158.     /*Boolean validator is a class the accepts and input i.e. Account Number
  159.      the checks if the entered input is zero then it returns false
  160.      else if entered Input is non zero then it compares the input with
  161.      the accounts Number which are already present if found it return True else
  162.      it return false
  163.      @param accNoInput
  164.      @return true or false*/
  165.     boolean validator ( int accNoInput )
  166.     {
  167.         if ( accNoInput == 0 )
  168.             return false;
  169.         boolean valid = accNo.contains ( accNoInput );
  170.         return valid;
  171.     }
  172.     /* Boolean validatorP method checks the given password
  173.     if it exist with correct accNo then it returns true
  174.     else it returns false*/
  175.     boolean validatorP ( String pw,int index )
  176.     {
  177.         if ( pw.equals ( accPword.get ( index ) ) )
  178.             return true;
  179.         return false;
  180.     }
  181.     /*This method helps to withdraw specific amount from the Account limited to minimum Balance */
  182.     void Withdraw (  )
  183.     {
  184.         boolean valid;
  185.         System.out.println ( "\n************************************************" );
  186.         System.out.println ( "=====WITHDRAW AMOUNT=====" );
  187.         try
  188.         {
  189.             Scanner src = new Scanner ( System.in );
  190.             System.out.print ( "Enter Your Acount Number : " );
  191.             int accNoInput = src.nextInt ( );
  192.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  193.             System.out.print ( "Enter Your Password : " );
  194.             String pw = src.next ( );
  195.             clear ( );
  196.             valid = validator ( accNoInput );
  197.             if ( valid == true )
  198.             {
  199.                 int index = accNo.indexOf ( accNoInput );
  200.                 boolean validp = validatorP ( pw,index );
  201.                 if ( validp == true )
  202.                 {
  203.                     System.out.println ( "Account Number : "+accNo.get ( index ) );
  204.                     System.out.printf ( "Account Balance: %.2f\n",accBal.get ( index ) );
  205.                     System.out.printf ( "Account Balance In Words : " );
  206.                     displayword (  ( int )Math.round ( accBal.get ( index ) ) );
  207.                     System.out.print ( " Rs " );
  208.                     int n = num ( bal );
  209.                     if (  n != 0 )
  210.                     {
  211.                         displayword (  n );
  212.                         System.out.println ( "Paise " );
  213.                     }
  214.                     System.out.print ( "Enter Amount you want to withdraw  : " );
  215.                     double amt = src.nextDouble (  );
  216.                     double checkamt = accBal.get ( index ) - amt;
  217.                     if ( checkamt < minBal )
  218.                         System.out.println ( "\n\nAs per Bank Rule you should maintain minimum balance of  Rs 500" );
  219.                     else
  220.                     {
  221.                         amt=amt * ( -1 );
  222.                         record = balRecord.elementAt ( index );
  223.                         record.add ( amt );
  224.                         accBal.set ( index, checkamt );
  225.                         System.out.println ( "\nAfter Updation..." );
  226.                         System.out.println ( "Account Number :  " + accNo.get ( index ) );
  227.                         System.out.printf ( "Account Balance: %.2f\n",+accBal.get ( index ) );
  228.                         System.out.printf ( "Account Balance In Words : " );
  229.                         displayword (  ( int )Math.round (  accBal.get (  index ) ) );
  230.                         System.out.print ( " Rs " );
  231.                         n = num (  bal );
  232.                         if (  n != 0 )
  233.                         {
  234.                             displayword (  n );
  235.                             System.out.println ( "Paise " );
  236.                         }
  237.                     }
  238.                 }
  239.                 else
  240.                     System.out.println ( "\nIncorrect Password" );
  241.             }
  242.             else
  243.                 System.out.println ( "\nInvalid Account Number\n" );
  244.             System.out.println ( "************************************************" );
  245.             System.out.println ( "\n\n" );
  246.         }catch (  Exception e )
  247.         {
  248.             errorDisplay (  e );
  249.         }
  250.     }
  251.     /*This Method Helps to deposit specific amount in the account limited to the Range of Integer value */
  252.     void Deposite ( )
  253.     {
  254.         boolean valid;
  255.         System.out.println ( "************************************************" );
  256.         System.out.println ( "=====DEPOSIT AMOUNT=====\n" );
  257.         try
  258.         {
  259.             Scanner src = new Scanner (  System.in  );
  260.             System.out.print ( "Enter Your Acount Number : " );
  261.             int accNoInput = src.nextInt ( );
  262.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  263.             System.out.print ( "Enter Your Password : " );
  264.             String pw = src.next ( );
  265.             clear ( );
  266.             valid = validator (  accNoInput );
  267.             if (  valid == true )
  268.             {
  269.                 int index = accNo.indexOf (  accNoInput );
  270.                 boolean validp = validatorP (  pw , index );
  271.                 if (  validp == true )
  272.                 {
  273.                     System.out.println ( "Account Number : " + accNo.get (  index ) );
  274.                     System.out.printf ( "Account Balance: %.2f\n", + accBal.get (  index ) );
  275.                     System.out.print ( "Account Balance In Words : " );
  276.                     displayword (   (  int ) Math.round ( accBal.get ( index ) ) );
  277.                     System.out.print ( " Rs " );
  278.                     int n = num ( bal );
  279.                     if (  n != 0 )
  280.                     {
  281.                         displayword (  n );
  282.                         System.out.println ( "Paise " );
  283.                     }
  284.                     System.out.print ( "Enter Amount you want to Deposit  : " );
  285.                     double amt = src.nextDouble( );
  286.                     double depamt = amt + accBal.get( index );
  287.                     accBal.set( index , depamt );
  288.                     record = balRecord.elementAt( index );
  289.                     record.add( amt );
  290.                     System.out.println ( "\nAfter Updation...");
  291.                     System.out.println ( "Account Number :  " + accNo.get ( index ) );
  292.                     System.out.printf ( "Account Balance: %.2f\n",+accBal.get ( index ) );
  293.                     System.out.printf ( "Account Balance In Words : ");
  294.                     displayword ( ( int ) Math.round ( accBal.get ( index ) ) );
  295.                     System.out.print ( " Rs " );
  296.                     n = num ( bal );
  297.                     if( n != 0 )
  298.                     {
  299.                         displayword ( n );
  300.                         System.out.println ( "Paise " );
  301.                     }
  302.                 }
  303.                 else
  304.                     System.out.println ( "\nIncorrect Password" );
  305.             }
  306.             else
  307.                 System.out.println ( "\nInvalid Account Number" );
  308.             System.out.println ( "************************************************" );
  309.             System.out.println ( "\n" );
  310.         }catch( Exception e )
  311.         {
  312.             errorDisplay( e );
  313.         }
  314.     }
  315.     void balRecord()
  316.     {
  317.         boolean valid;
  318.         System.out.println( "************************************************" );
  319.         System.out.println( "=====BALANCE RECORD=====\n" );
  320.         try
  321.         {
  322.             Scanner src = new Scanner( System.in );
  323.             System.out.print ( "Enter Your Acount Number : " );
  324.             int accNoInput = src.nextInt ( );
  325.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  326.             System.out.print ( "Enter Your Password : " );
  327.             String pw = src.next ( );
  328.             clear ( );
  329.             valid = validator ( accNoInput ) ;
  330.             if( valid == true )
  331.             {
  332.                 int index = accNo.indexOf ( accNoInput );
  333.                 boolean validp = validatorP ( pw,index );
  334.                 if( validp == true )
  335.                 {
  336.                     record = balRecord.elementAt( index );
  337.                     System.out.println ("Note : \nFor Withdrawal Value Signed With '-' \nFor Deposit Value Unsigned ");
  338.                     for( int i = 0 ; i < record.size() ; i++ )
  339.                         System.out.println ( ( i + 1 ) + ") Rs " + record.elementAt ( i ) );
  340.                     System.out.printf ("Account Balance: %.2f\n", + accBal.get ( index ) );
  341.                     System.out.printf ("Account Balance In Words : ");
  342.                     displayword ( ( int ) Math.round ( accBal.get ( index ) ) );
  343.                     System.out.print ( " Rs " );
  344.                     int n = num ( bal );
  345.                     if( n != 0 )
  346.                     {
  347.                         displayword ( n );
  348.                         System.out.println ( "Paise " );
  349.                     }
  350.                 }
  351.                 else
  352.                     System.out.println ("Incorrect Password" );
  353.             }
  354.             else
  355.                 System.out.println ( "Invalid Account Number" );
  356.             System.out.println ( "************************************************" );
  357.             System.out.println ( "\n" );
  358.         }catch ( Exception e )
  359.         {
  360.             errorDisplay ( e );
  361.         }
  362.     }
  363.     /*This account helps to delete an account from already present account */
  364.     void delete ( )
  365.     {
  366.         boolean valid;
  367.         System.out.println ( "************************************************" );
  368.         System.out.println ( "=====DELETE ACCOUNT=====" );
  369.         try
  370.         {
  371.             Scanner src = new Scanner ( System.in );
  372.             System.out.print ( "Enter Your Account Number : " );
  373.             int accNoInput = src.nextInt();
  374.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  375.             System.out.print ( "Enter Your Password :  " );
  376.             String pw = src.next ( );
  377.             clear ( );
  378.             valid = validator ( accNoInput );
  379.             if ( valid == true )
  380.             {
  381.                 int index = accNo.indexOf ( accNoInput );
  382.                 boolean validp = validatorP ( pw,index );
  383.                 if ( validp == true )
  384.                 {
  385.                     accNo.remove ( index );
  386.                     accName.remove ( index );
  387.                     accType.remove ( index );
  388.                     accBal.remove ( index );
  389.                     accPword.remove ( index );
  390.                     balRecord.remove ( index );
  391.                     System.out.println ( "\nAccount No : " + accNoInput+ " deleted Successfuly" );
  392.                 }
  393.                 else
  394.                     System.out.println ( "\nIncorrect Password" );
  395.             }
  396.             else
  397.                 System.out.println ( "\nInvalid Account Number" );
  398.             System.out.println ( "************************************************" );
  399.             System.out.println ( "\n" );
  400.         }catch ( Exception e )
  401.         {
  402.             errorDisplay ( e );
  403.         }
  404.     }
  405.     /*this method Modify the name of the Account holder when entered a valid account Number*/
  406.     void modifyAcc ( )
  407.     {
  408.         boolean valid;
  409.         System.out.println ( "************************************************" );
  410.         System.out.println ( "=====MODIFY ACCOUNT=====" );
  411.         try
  412.         {
  413.             DataInputStream in = new DataInputStream ( System.in );
  414.             System.out.print ( "Enter Your Account Number : " );
  415.             int accNoInput = Integer.parseInt ( in.readLine ( ) );
  416.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  417.             System.out.print ( "Enter Your Password : " );
  418.             String pw = in.readLine ( );
  419.             clear ( );
  420.             valid = validator ( accNoInput );
  421.             if ( valid == true )
  422.             {
  423.                 int index = accNo.indexOf ( accNoInput );
  424.                 boolean validp = validatorP ( pw , index );
  425.                 if ( validp == true )
  426.                 {
  427.                     System.out.print ( "1) Change Name\n2) Change Password\n3) Both\nEnter Your Choice : " );
  428.                     int c = Integer.parseInt ( in.readLine ( ) );
  429.                     switch ( c )
  430.                     {
  431.                         case 1:
  432.                             System.out.println ( "Old Account Name : " + accName.get ( index ) );
  433.                             System.out.print ( "Enter Your New Account Name : " );
  434.                             String str = in.readLine ( );
  435.                             accName.set ( index , str );
  436.                             clear ( );
  437.                             System.out.println ( "Account Name Modified" );
  438.                             break;
  439.                         case 2:
  440.                             System.out.println ( "Old Password Name : " + accPword.get ( index ) );
  441.                             System.out.println ( "Please See That No one Is Beside You While Entering The New Password !!!!!" );
  442.                             System.out.print ( "Enter Your New Account Password : " );
  443.                             pw = in.readLine ( );
  444.                             accPword.set ( index , pw );
  445.                             clear ( );
  446.                             System.out.println ( "Account Password Modified" );
  447.                             break;
  448.                         case 3:
  449.                             System.out.println ( "Old Account Name : " + accName.get ( index ) );
  450.                             System.out.print ( "Enter Your New Account Name : " );
  451.                             str = in.readLine ( );
  452.                             accName.set ( index , str );
  453.                             System.out.println ( "Old Password Name : " + accPword.get ( index ) );
  454.                             System.out.println ( "Please See That No one Is Beside You While Entering The New Password !!!!!" );
  455.                             System.out.print ( "Enter Your New Account Password : " );
  456.                             pw = in.readLine ( );
  457.                             accPword.set ( index , pw );
  458.                             clear ( );
  459.                             System.out.println ( "Account Name & Password Modified" );
  460.                             break;
  461.                         default :
  462.                             System.out.println ( "Invalid Input" );
  463.                             break;
  464.                     }  
  465.                 }
  466.                 else
  467.                     System.out.println ( "\nIncorrect Password" );
  468.             }
  469.             else
  470.                 System.out.println ( "\nInvalid Account Number" );
  471.             System.out.println ( "\n************************************************" );
  472.             System.out.println ( "\n" );
  473.         }catch ( Exception e )
  474.         {
  475.             errorDisplay ( e );
  476.         }
  477.     }
  478.     void DisplayBal ( )
  479.     {
  480.         boolean valid;
  481.         System.out.println ( "\n************************************************" );
  482.         System.out.println ( "=====DISPLAYING BALANCE OF CUSTOMER=====\n" );
  483.         try
  484.         {
  485.             Scanner src = new Scanner ( System.in );
  486.             System.out.print ( "Enter Your Account Number : " );
  487.             int accNoInput = src.nextInt ( );
  488.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  489.             System.out.print ( "Enter Your Password : " );
  490.             String pw = src.next ( );
  491.             clear ( );
  492.             valid = validator ( accNoInput );
  493.             if ( valid == true )
  494.             {
  495.                 int index = accNo.indexOf ( accNoInput );
  496.                 boolean validp = validatorP ( pw , index );
  497.                 if ( validp == true )
  498.                 {
  499.                     System.out.println ( "Account Number : " + accNo.get ( index ) );
  500.                     System.out.printf ( "Account Balance: Rs. %.2f\n",accBal.get ( index ) );
  501.                     displayword (  ( int)Math.round ( accBal.get ( index ) ) );
  502.                     System.out.print ( " Rs " );
  503.                     int n = num ( bal );
  504.                     if ( n != 0 )
  505.                     {
  506.                         displayword ( n );
  507.                         System.out.println ( "Paise " );
  508.                     }
  509.                 }
  510.                 else
  511.                     System.out.println ( "\nIncorrect Password" );
  512.             }
  513.             else
  514.                 System.out.println ( "\nInvalid Account Number\n" );
  515.             System.out.println ( "\n************************************************" );
  516.             System.out.println ( "\n" );
  517.         }catch ( Exception e )
  518.         {
  519.             errorDisplay ( e );
  520.         }
  521.     }
  522.     public void balTrans ( )
  523.     {
  524.         boolean valid1,valid2,validp;
  525.         System.out.println ( "\n************************************************" );
  526.         System.out.println ( "=====BALANCE TRANSFER=====\n" );
  527.         try
  528.         {
  529.             Scanner src = new Scanner ( System.in );
  530.             System.out.print ( "Enter Your Account Number : " );
  531.             int accNoInput1 = src.nextInt ( );
  532.             System.out.println ( "Please See That No one Is Beside You While Entering The Password !!!!!" );
  533.             System.out.print ( "Enter Your Password : " );
  534.             String pw = src.next ( );
  535.             int index1 = accNo.indexOf ( accNoInput1 );
  536.             validp = validatorP ( pw , index1 );
  537.             clear ( );
  538.             System.out.print ( "Enter Account Number Of Destination : " );
  539.             int accNoInput2 = src.nextInt ( );
  540.             valid1 = validator ( accNoInput1 );
  541.             valid2 = validator ( accNoInput2 );
  542.             if ( valid1 == true && validp == true )
  543.             {
  544.                 if ( valid2 == true )
  545.                 {
  546.                     int index2 = accNo.indexOf ( accNoInput2 );
  547.                     record = balRecord.elementAt ( index1 );
  548.                     Vector record2 = new Vector ( );
  549.                     record2 = balRecord.elementAt ( index2 );  
  550.                     System.out.println ( "Balance : " +accBal.get ( index1 ) );
  551.                     System.out.print ( "Amount To Be Transfered : " );
  552.                     double amt = src.nextDouble ( );
  553.                     double checkamt = accBal.get ( index1 ) - amt;
  554.                     if ( checkamt < minBal )
  555.                         System.out.println ( "\n\nAs per Bank Rule you should maintain minimum balance of  Rs 500" );
  556.                     else
  557.                     {
  558.                         accBal.set ( index1 , checkamt );
  559.                         record.add (  (  -1 ) * amt );
  560.                         record2.add ( amt );
  561.                         amt = accBal.get ( index2 ) + amt;
  562.                         accBal.set ( index2 , amt );
  563.                         System.out.println ( "\nAfter Updation..." );
  564.                         System.out.println ( "Account Number :  " + accNo.get ( index1 ) );
  565.                         System.out.printf ( "Account Balance : %.2f\n",accBal.get ( index1 ) );
  566.                         System.out.printf ( "Account Balance In Words : " );
  567.                         displayword (  ( int)Math.round ( accBal.get ( index1 ) ) );
  568.                         System.out.print ( " Rs " );
  569.                         int n = num ( bal );
  570.                         if ( n != 0 )
  571.                         {
  572.                             displayword ( n );
  573.                             System.out.println ( "Paise " );
  574.                         }
  575.                     }
  576.                 }
  577.                 else
  578.                     System.out.println ( "Invalid Destination Acount Number" );
  579.             }
  580.             else
  581.                 System.out.println ( "\nInvalid Source Account Number or Incorrect Password\n" );
  582.             System.out.println ( "************************************************" );
  583.             System.out.println ( "\n\n" );
  584.         }catch ( Exception e )
  585.         {
  586.             errorDisplay ( e );
  587.         }
  588.     }
  589.     /*  num method is to get the the two nos after decimal pt */
  590.     public static int num ( String bal )
  591.     {
  592.         int n = bal.indexOf ( ".");
  593.         if ( n == -1 )
  594.             return 0;
  595.         String s1 = bal.substring ( 0 , n );
  596.         String s2 = bal.substring ( n+1 , bal.length ( ) );
  597.         char s3 [] = new char[ s2.length ( ) ];
  598.         s3 = s2.toCharArray ( );
  599.         int number;
  600.         if( s3[ 0 ] != '0' && s3[ 1 ] != '0')
  601.             number = 10* (  ( int ) s3[ 0 ] - 48 )+ (  ( int ) s3[ 1 ] - 48 );
  602.         else
  603.             number = 0;
  604.         return number;
  605.     }
  606.     /* word method is to get the balance in words*/
  607.     public static String word ( int num )
  608.     {
  609.         int n2 = num / 10;
  610.         String sf = "";
  611.         if ( num >= 10 & num < 20 )
  612.         {
  613.             switch ( num )
  614.             {
  615.                 case 10:
  616.                     sf = "Ten";
  617.                     break;
  618.                 case 11:
  619.                     sf = "Eleven";
  620.                     break;
  621.                 case 12:
  622.                     sf = "Twelve";
  623.                     break;
  624.                 case 13:
  625.                     sf = "Thirteen";
  626.                     break;
  627.                 case 14:
  628.                     sf = "Fourteen";
  629.                     break;
  630.                 case 15:
  631.                     sf = "Fifteen";
  632.                     break;
  633.                 case 16:
  634.                     sf = "Sixteen";
  635.                     break;
  636.                 case 17:
  637.                     sf = "Seventeen";
  638.                     break;
  639.                 case 18:
  640.                     sf = "Eighteen";
  641.                     break;
  642.                 case 19:
  643.                     sf = "Nineteen";
  644.                     break;
  645.             }
  646.             return sf;
  647.         }
  648.         if ( n2 >= 2 && n2 <= 9 )
  649.         {
  650.             switch ( n2 )
  651.             {
  652.                 case 2:
  653.                     sf = " Twenty";
  654.                     break;
  655.                 case 3:
  656.                     sf = " Thirty";
  657.                     break;
  658.                 case 4:
  659.                     sf = " Fourty";
  660.                     break;
  661.                 case 5:
  662.                     sf = " Fifty";
  663.                     break;
  664.                 case 6:
  665.                     sf = " Sixty";
  666.                     break;
  667.                 case 7:
  668.                     sf = " Seventy";
  669.                     break;
  670.                 case 8:
  671.                     sf = " Eighty";
  672.                     break;
  673.                 case 9:
  674.                     sf = " Ninety";
  675.                     break;
  676.             }
  677.         }
  678.         num = num % 10;
  679.         switch ( num )
  680.         {
  681.             case 1:
  682.                 sf = sf + " One ";
  683.                 break;
  684.             case 2:
  685.                 sf = sf + " Two ";
  686.                 break;
  687.             case 3:
  688.                 sf = sf + " Three ";
  689.                 break;
  690.             case 4:
  691.                 sf = sf + " Four ";
  692.                 break;
  693.             case 5:
  694.                 sf = sf + " Five ";
  695.                 break;
  696.             case 6:
  697.                 sf = sf + " Six ";
  698.                 break;
  699.             case 7:
  700.                 sf = sf + " Seven ";
  701.                 break;
  702.             case 8:
  703.                 sf = sf + " Eight ";
  704.                 break;
  705.             case 9:
  706.                 sf = sf + " Nine ";
  707.                 break;
  708.         }
  709.         return sf;
  710.     }      
  711.     /* displayword method returns the balance in words*/
  712.     public static void displayword ( int n )
  713.     {
  714.         int crore,lakh,th,hun;
  715.         String sc,sl,sth,shun,sf = "";
  716.         if ( n / 10000000 >= 1 )
  717.         {
  718.             crore = n / 10000000;
  719.             sc = word ( crore );
  720.             System.out.print ( sc + " Crore " );
  721.             n = n % 10000000;
  722.         }
  723.         if ( n / 100000 >= 1 )
  724.         {
  725.             lakh = n / 100000;
  726.             sl = word ( lakh );
  727.             System.out.print ( sl + "Lakhs " );
  728.             n = n % 100000;
  729.         }
  730.         if ( n / 1000 >= 1 )
  731.         {
  732.             th = n / 1000;
  733.             sth = word ( th );
  734.             System.out.print ( sth + "Thousands" );
  735.             n = n % 1000;
  736.         }
  737.         if ( n /100 >= 1 )
  738.         {
  739.             hun = n / 100;
  740.             shun = word ( hun );
  741.             System.out.print ( shun + "Hundred " );
  742.             n = n % 100;
  743.         }
  744.         if ( n != 0)
  745.         {
  746.             System.out.print ( "and " );
  747.             sf = word ( n );
  748.         }
  749.         System.out.print ( sf );
  750.     }
  751.     void errorDisplay ( Exception e )
  752.     {
  753.         System.out.println ( "\n             ******Warning******             " );
  754.         System.out.println ( "\nThere was an Technical Error while Creating " );
  755.         System.out.println ( "your account due to Mismatched Values you have" );
  756.         System.out.println ( "Entered .'Its not My Fault...!!!!!'" );
  757.         System.out.println ( "************************************************\n" );
  758.     }
  759.     void clear ( )
  760.     {
  761.         for ( int i = 0 ; i < 620 ; i++ )
  762.             System.out.println ( "\b" );
  763.     }
  764. }
  765. /*class Info Contains Elements Required for storing User entered values */
  766. class Info
  767. {
  768.     /*accName : Stores the Name of Account ( String)*/
  769.     public Vector < String > accName = new Vector < String > ( ) ;
  770.     /*accNo : Stores the Account Number ( Integer)*/
  771.     public Vector < Integer > accNo = new Vector < Integer > ( );
  772.     /*accPword : Stores Password Of The Account */
  773.     public Vector < String > accPword = new Vector < String > ( ) ;
  774.     /*accType : Stores Account Type  ( Current / Savings)  ( String)*/
  775.     public Vector < String > accType = new Vector < String > ( ) ;
  776.     /*accBal : Stores the Account Balance ( Double)*/
  777.     public Vector < Double > accBal = new Vector < Double > ( );
  778.     /*balRecord : stores the balance history / record ( Vector ) */
  779.     public Vector < Vector > balRecord = new Vector < Vector > ( );
  780.     String pw = new String ( );
  781.     String bal = new String ( );
  782.     String current = new String ( );
  783.     String savings = new String ( );
  784. }
  785. /*This is the Main Class*/
  786. public class MainBank
  787. {  
  788.     public static void main ( String args [] )
  789.     {
  790.         int choice = 0;
  791.         //BO_obj is the object Created for Accessing BankOperations Class
  792.         BankOperations BO_obj = new BankOperations ( );
  793.         do
  794.         {
  795.             System.out.println ( "|============================================|" );
  796.             System.out.println ( "|          WELCOME TO RIZVI's BANK           |" );
  797.             System.out.println ( "|============================================|" );
  798.             System.out.println ( "|********... Select Your Choices ...*********|" );
  799.             System.out.println ( "|                                            |" );
  800.             System.out.println ( "| 1) New Record Entry                        |" );
  801.             System.out.println ( "| 2) Display Record Details                  |" );
  802.             System.out.println ( "| 3) Display Bal                             |" );
  803.             System.out.println ( "| 4) Deposit                                 |" );
  804.             System.out.println ( "| 5) Withdraw                                |" );
  805.             System.out.println ( "| 6) Modify                                  |" );
  806.             System.out.println ( "| 7) Balance Transfer                        |" );
  807.             System.out.println ( "| 8) Balance Record                          |" );
  808.             System.out.println ( "| 9) Delete                                  |" );
  809.             System.out.println ( "| 10) Exit                                   |" );
  810.             System.out.println ( "|********************************************|" );
  811.             System.out.print ( "Enter your choice :  " );
  812.             Scanner src = new Scanner ( System.in );   
  813.             try
  814.             {
  815.                 choice = src.nextInt ( );
  816.                 System.out.println ( "\n" );
  817.                 switch ( choice )
  818.                 {
  819.                     case 1:
  820.                         BO_obj.newEntry ( );
  821.                         break;
  822.                     case 2:
  823.                         BO_obj.Display ( );
  824.                         break;
  825.                     case 3:
  826.                         BO_obj.DisplayBal ( );
  827.                         break;
  828.                     case 4:
  829.                         BO_obj.Deposite ( );
  830.                         break;
  831.                     case 5:
  832.                         BO_obj.Withdraw ( );
  833.                         break;
  834.                     case 6:
  835.                         BO_obj.modifyAcc ( );
  836.                         break;
  837.                     case 7:
  838.                         BO_obj.balTrans ( );
  839.                         break;
  840.                     case 8:
  841.                         BO_obj.balRecord ( );
  842.                         break;
  843.                     case 9:
  844.                         BO_obj.delete ( );
  845.                         break;
  846.                     case 10:
  847.                         System.out.println ( "\n*********Thankyou For visiting**********" );
  848.                         break;
  849.                 }  
  850.             }catch ( Exception e )
  851.             {
  852.                 System.out.println ( "\nWrong Entry! Wrong Entry! Wrong Entry!\n\n" );
  853.             }
  854.         }while ( choice != 10 );
  855.     }
  856. }
Add Comment
Please, Sign In to add comment