Question Solved1 Answer Java You have been hired as a programmer by a major bank. Your first project is a small banking transaction system. Each account consists of a number and a balance. The user of the program (the teller) can create a new account, as well as perform deposits, withdrawals, and balance inquiries. Initially, the account information of existing customers is to be read into a pair of parallel arrays--one for account numbers, the other for balances. The bank can handle up to MAX_NUM accounts. Use the following method to read in the data values: public static int readAccts(int[] acctNum, double[] balance, int maxAccts) This method fills up the account number and balance arrays (up to maxAccts) by reading from an input file until EOF is reached, and counting how many accounts are read in. It returns the actual number of accounts read in (later referred to as numAccts). After initialization, the main program prints the initial database of accounts and balances. Use method printAccts() described below. The program then allows the user to select from the following menu of transactions: Select one of the following: W - Withdrawal D - Deposit N - New account B - Balance Q – Quit X – Delete Account – Extra Credit Use the following method to produce the menu: public static void menu() This method only displays the menu. The main program then prompts the user for a selection. You should verify that the user has typed in a valid selection (otherwise print out an error message and repeat the prompt). Once the user has entered a selection, one of the following methods should be called to perform the specific transaction. At the end, before the user quits, the program prints the final contents of the account and balance arrays. public static int findAcct(int[] acctNum, int numAccts, int account); This method returns the index of account in the acctNum array if the account exists, and -1 if it doesn't. It is called by all the remaining methods. public static void withdrawal(int[] acctNum, double[] balance, int numAccts); This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the withdrawal. If the account does not contain sufficient funds, it prints an error message and does not perform the transaction. pubic static void deposit(int[] acctNum, double[] balance, int num_accts); This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the deposit. public static int newAcct(int[] acctNum, double[] balance, int numAccts); This method prompts the user for a new account number. If the account already exists, it prints an error message. Otherwise, it adds the account to the acctNum array with an initial balance of 0. It returns the new number of accounts. public static void balance(int[] acctNum, double[] balance, int numAccts); This method prompts the user for an account number. If the account does not exist, it prints an error message. Otherwise, it prints the account balance. public static void printAccts(int[] acctNum, double[] balance, int numAccts);

5T9KB2 The Asker · Computer Science

Java

You have been hired as a programmer by a major bank. Your first project is a small banking transaction system. Each account consists of a number and a balance. The user of the program (the teller) can create a new account, as well as perform deposits, withdrawals, and balance inquiries.

Initially, the account information of existing customers is to be read into a pair of parallel arrays--one for account numbers, the other for balances. The bank can handle up to MAX_NUM accounts. Use the following method to read in the data values:

     public static int readAccts(int[] acctNum, double[] balance, int maxAccts)

This method fills up the account number and balance arrays (up to maxAccts) by reading from an input file until EOF is reached, and counting how many accounts are read in. It returns the actual number of accounts read in (later referred to as numAccts).

After initialization, the main program prints the initial database of accounts and balances. Use method printAccts() described below.

The program then allows the user to select from the following menu of transactions: Select one of the following:

W - Withdrawal D - Deposit
N - New account B - Balance

Q – Quit

X – Delete Account – Extra Credit

Use the following method to produce the menu:

     public static void menu()

This method only displays the menu. The main program then prompts the user for a selection. You should verify that the user has typed in a valid selection (otherwise print out an error message and repeat the prompt).

Once the user has entered a selection, one of the following methods should be called to perform the specific transaction. At the end, before the user quits, the program prints the final contents of the account and balance arrays.

     public static int findAcct(int[] acctNum, int numAccts, int account);

This method returns the index of account in the acctNum array if the account exists, and -1 if it doesn't. It is called by all the remaining methods.

     public static void withdrawal(int[] acctNum, double[] balance, int numAccts);

This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the withdrawal. If the account does not contain sufficient funds, it prints an error message and does not perform the transaction.

     pubic static void deposit(int[] acctNum, double[] balance, int num_accts);

This method prompts the user for the account number. If the account does not exist, it prints an error message. Otherwise, it asks the user for the amount of the deposit.

     public static int newAcct(int[] acctNum, double[] balance, int numAccts);

This method prompts the user for a new account number. If the account already exists, it prints an error message. Otherwise, it adds the account to the acctNum array with an initial balance of 0. It returns the new number of accounts.

     public static void balance(int[] acctNum, double[] balance, int numAccts);

This method prompts the user for an account number. If the account does not exist, it prints an error message. Otherwise, it prints the account balance.

     public static void printAccts(int[] acctNum, double[] balance, int numAccts);

More
See Answer
Add Answer +20 Points
Community Answer
PLN3JX The First Answerer
See all the answers with 1 Unlock
Get 4 Free Unlocks by registration

  Note: Could you plz go through this code and let me know if u need any changes in this.Thank You ================================= // BankAccounts.java import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class BankAccounts {     /*      * Creating an Scanner class object which is used to get the inputs      * entered by the user      */     static Scanner sc = new Scanner(System.in);     public static void main(String[] args) {         int num_accts=0;         char ch;         final int MAX_ACCTS=100;     int accNum[]=new int[MAX_ACCTS];     double balance[]=new double[MAX_ACCTS];          num_accts=readAccts(accNum, balance, MAX_ACCTS);          while(true)     {             menu();             System.out.print("Enter Choice :");             ch=sc.next(".").charAt(0);             switch(ch)             {             case 'W':             case 'w':{                     withdrawal(accNum, balance, num_accts);                  continue;             }             case 'D':             case 'd':{                     deposit(accNum, balance, num_accts);                     continue;             }             case 'N':             case 'n':{                     num_accts=newAcct(accNum, balance, num_accts);                 continue;             }             case 'B':             case 'b':{                     balance(accNum, balance, num_accts);                 continue;             }             case 'Q':             case 'q':{                     break;             }             case 'X':             case 'x':{                     num_accts=deleteAcct(accNum, balance, num_accts);                 continue;             }                            }             break;                  }                   printAccts(accNum, balance,num_accts);                                       }     public static int deleteAcct(int[] acctNum, double[] balance, int numAccts)     {         int account;         System.out.print("Enter an account number :");         account=sc.nextInt();         int index=findAcct(acctNum, numAccts, account);         if(index!=-1)         {             for(int i=index;i<numAccts-1;i++)             {                 acctNum[i]=acctNum[i+1];                 balance[i]=balance[i+1];             }             numAccts--;             System.out.println("** Account Deleted Successfully **");         }         else         {             System.out.println("Account not found");         }         return numAccts;     }     public static void withdrawal(int[] acctNum, double[] balance, int numAccts)     {         int account;         System.out.print("Enter an account number :");         account=sc.nextInt();         int index=findAcct(acctNum, numAccts, account);         if(index!=-1)         {             while(true)             {                 System.out.print("Enter Amount to withdraw :$");                 double amt=sc.nextDouble();                 if(amt<=0){                     System.out.println("** Invalid.Must be >=0 **");                 }                 else if((balance[index]-amt)<0)                 {                     System.out.println("** Insufficient funds **");                 }                 else                 {                     System.out.println("Transaction Type:Withdrawl");                     System.out.println("Account Number:"+account);                     System.out.println("Currecnt Balance:$"+balance[index]);                     System.out.println("Amount to Deposit:$"+amt);                                                               balance[index]-=amt;                     System.out.println("New Balance:$"+balance[index]);                     break;                 }                              }         }         else         {             System.out.println("Account not found");         }     }     public static void deposit(int[] acctNum, double[] balance, int num_accts)     {         int account;         System.out.print("Enter an account number :");         account=sc.nextInt();         int index=findAcct(acctNum, num_accts, account);         if(index!=-1)         {             while(true)             {                 System.out.print("Enter Amount to deposit :$");                 double amt=sc.nextDouble();                 if(amt<=0){                     System.out.println("** Invalid.Must be >=0 **");                 }                 else       &# ... See the full answer