Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm done my code and have everything done, except for the part where i have to use a multi dimensional array in my program or two dimensional arrays, if you have any suggestions please post it as a solution thanks in advance.

What I have tried:

/*Skandan Vecham
 * Mini Bank Application
import java.util.*;
public class ATM {

    public static void main(String[] args) {
        Scanner input=new Scanner (;
        //variables that store account number and pin
        String acctNum,pin="";
        // original balance which helps decide if the account information is true or false
        String originalBalance="error";
        //variables to store deposit and withdrawal amounts
        double depositAmount, withdrawAmount=0;
        // main menu option
        int mainMenu=0;
        // counter to lock user out
        int counter=3;
        // loop for user input of account number and pin
            System.out.println("Enter the account number:");
            System.out.println("Enter the pin:");
            // if statements to decide if user has tried to many times
            // if statement that kicks user out of program
                System.out.println("\nMaximum amount of attempts reached\nPlease visit a branch or call the bank at your convinence");
            // if statement that breaks the loop and gets on with the program provided that the information given is true
            else if(!(originalBalance.equals("error")))
        // converts balance which is in string to double for calculations
        double balance=Double.parseDouble(originalBalance);
        // do while loop to repeat the mainMenu multiple times
            // if statements that take user to desired place
            // if statement 1 takes user to withdrawal
            if (mainMenu==1)
                //Asks how much money the user would like to withdraw, and if withdraw amount is 
                // greater than current balance it will not process the request
                System.out.println("How much money would you like to withdraw");
                // while loop repeats the process
                    System.out.println("Insufficient Funds\nBalance= $"+balance+"\nTry again");
            // opens deposit method and deposits users choice of money
            else if (mainMenu==2)
                System.out.println("How much money would you like to deposit");
            // method that displays balance
            else if(mainMenu==3)
            // method that ends the program
            else if(mainMenu==4)
                System.out.println("Thank you for visiting the Bank of Skandanavia");
    // shows the balance of the account
    public static void displayBalance(double balance) {
        //printf $%.2f\n rounds decimals
        System.out.printf("Account Balance= $%.2f\n",balance);
// withdraw method which contains  the withdrawAmount and balance
    public static double withdraw(double withdrawAmount, double balance) 
        //printf $%.2f\n rounds decimals
        double newBalance=0;
        System.out.printf("Balance= $%.2f\n",newBalance);
        return newBalance;
// deposit method that deposits userinput into their accounts
    public static double deposit(double depositAmount, double balance) 
        double newBalance=0;
        System.out.printf("Balance= $ %.2f\n",newBalance);
        return newBalance;

// main menu method, directs user in the desired direction    
    public static int mainMenuOption() {
        Scanner input=new Scanner(;
        int userInput=0;
        System.out.println("\nWhat would you like to do today?");
        System.out.println("1. withdrawal");
        System.out.println("2. Deposit");
        System.out.println("3. Bank Balance");
        System.out.println("4. Exit");
        return userInput;
// validation of the users information
    public static String validation(String acctNum,String pin) {
        // array that holds account number, account pin, and account balance
        String accountNums[]= {"1234567","2345678","3456789","456789","76589"};
        String accountPin[]= {"1234","2345","3456","4567","5678"};
        double accountBal[]= {56.8,89.6,97.3,110.9,996.8};
        // result variable helps the original balance in the main method to decide if user input is false
        String result="";
        // to convert double account balance to string so it can return to main method
        String accountBalS="";
        int counter=0;
        // for loop to check if account information matches arrays 
        for(int x=0;x<5;x++)
            // actual conversion of double to string
                return result;
            // if account number or pin is invalid then this if statement will run
            else if(!(accountNums[x].equals(acctNum)||(accountPin[x].equals(pin)))&&counter==5)
                System.out.println("Account number or pin is invalid try again");
                return result;
        return result;
Updated 8-Nov-18 4:40am
CPallini 8-Nov-18 9:02am    
Why multidimensional arrays? An array of 'account' objects would fit nicely.
Member 14045850 8-Nov-18 9:12am    
It is required for my assignment
CPallini 8-Nov-18 16:57pm    
Your assignment is bogus.
Anyway, I understand, you have to comply.

Looks like you get to do some re-factoring for your account methods...

String AccountInfo[][] = {
  {"1234567","1234", "56.8" },
  {"2345678", ""2345", "89.6"},
  {"3456789", "3456", "97.3"},
  {"456789", "4567", "110.9"},
  {"76589", "5678", "996.8"}
Share this answer
Member 14045850 8-Nov-18 10:45am    
Thanks, (supposed to be a 5 start)
CPallini 8-Nov-18 16:56pm    
Looks like you a have a dimension too much.
MadMyche 8-Nov-18 17:36pm    
yep I do
Member 14045850 8-Nov-18 17:43pm    
Hey guys thanks a lot for your help, i just handed in the assignment, and i think I'll do prty good.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900