Question: Hello, I have troubles with my coding right now. It would be great if you can take a look of my code and help me

Hello, I have troubles with my coding right now. It would be great if you can take a look of my code and help me fix the problems. Very appreciate. import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; class ATM_Machine { public ArrayList identity = new ArrayList(); public int[] balance = new int [100]; public int count = 0; public void register(){ Scanner scan = new Scanner(System.in); for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); String set=""; System.out.println("First Name:"); String fName = scan.nextLine(); set += fName + " "; System.out.println("Last Name:"); String lName = scan.nextLine(); set += lName + " "; System.out.println("account number: " + count+" Welcome! " + set); for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); identity.add(count,set); balance[count]= 0; count++; } public void username(){ Scanner scan = new Scanner(System.in); for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); System.out.println("username:"); String uName = scan.nextLine(); System.out.println("password:"); String pWord = scan.nextLine(); System.out.println("account number:"); int aNumber2 = scan.nextInt(); for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); if(aNumber2<=0){ System.out.println("Incorrect input"); username(); } else if(aNumber2 <=count){ } else{ System.out.println("The number is incorrect, please register first"); register(); } } public static void main(String arg[]) throws IOException { Scanner scan = new Scanner(System.in); boolean n = true; while(n){ System.out.println("Welcome to HRA ATM Machine!"); System.out.println("Enter 1 to login"); System.out.println("Enter 2 to register"); System.out.println("Enter any letter to access next menu"); String x = scan.nextLine(); for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); if(x.equals("1")||x.equals("2")){ for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(); if(x.equals("1")){ username(); } else if(x.equals("2")){ register(); username(); } } else{ System.out.println("Do you want to startover?(Yes/No)"); String cycle = scan.nextLine(); boolean n2 = true; while(n2){ if(cycle.equals("Yes")){ n2 = false; } else if(cycle.equals("No")){ n = false; n2 = false; for(int i = 0; i<40;i++){ System.out.print("-"); } System.out.println(" Thanks for using HRA ATM machine, have a nice day! "); for(int i = 0; i<40;i++){ System.out.print("-"); } } else{ System.out.println("Please retype"); cycle = scan.nextLine(); } } } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!