I need help for this assignment I'm doing for school since I can't figure out how to do it. Also I tried to fix the problem over the internet by look up for answers but I can't find any answer for my specific problem since I have some specific guideline that I have to follow for this assignment, so I thought the best idea was to post it on a forum since I'm going to get answered specifically for my problem.
These are the following guidelines that I have to follow:
This is the code that I have so far, the variables I used are different since I can't use the same variables as my class mates, so they're a bit odd. I still have to do the withdraw method, the passcode change method, the login method, the deposit method, loop, and errorcheck and I think that's it, if there's anything else that I missed that is in the guidelines then please correct me in the thread and give me a solution for it please. I tried solving the methods myself by putting in solutions from the internet but they don't match the guidelines and variables that I have, which causes problems that I can't fix, hopefully someone is able to fully help me so I can finish this frustrating assignment that has only cost me time and trouble.
These are the following guidelines that I have to follow:
- You are required to write a program (java class) to create a system for a bank ATM machine.
- Hard code the users for the system. Each user will have a name, password, and balance and overdraft facility. (These must all be stored in arrays.)
- The user will be asked to log in to the ATM using a method which should return the position (index) of the user in the array.
- Once they log in they will have a Display Menu (method) with options to View Bank Statement (method), Change Password (method), Deposit Money (method), Withdraw Money (method) and Exit (method). The menu should loop until the user chooses to Exit. (The new password cannot be a password that is already in use.)
- The arrays must be updated when the user deposits or withdraws money or changes a password.
- The user can only withdraw more money than they have in their account if they have an overdraft facility.
- There is no limit on the overdraft.
- All inputs must be validated for error checking using a method.
Code
import java.util.Scanner;//java library class
public class Assigment2 {//start class
//global variable
static int creditsbalanceArray []={156,256,504};// user currency balance
static String nameArray []={"Molly","Connor","Shane"};// user name
static int passcodeArray []= {6543,7654,8765};// user passcode
static int overdraftArray []={1,2,3};// user overdraft
static int passcode;// user passcode
static Scanner input = new Scanner(System.in);//static Scanner input
static int index;// user index
public static void main(String[] args) {//start main method
showAllUsers();//show All user variable
loginBankMachine();//login Bank Machine variable
showAlternativeOptions();//show Alternative Options variable
}//end main method
//METHODOLOGY||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public static void showAllUsers(){//start showAllUsers method
System.out.println(" All Users");// All Users
System.out.println("INDEX\tNAME\t$ BAL\tPASSCODE");//user options
for(int i=0;i<creditsbalanceArray.length;i++){//intializing credit balance Array
System.out.println(i+"\t"+nameArray[i]+"\t"+creditsbalanceArray[i]+"\t"+passcodeArray[i]);//displaying arrays
}// end for loop
}//end showAllUsers method
public static void loginBankMachine(){//start login method
int[] accountPasscode;
int[] d;
int found = 0;
System.out.println("Welcome " + d+"\nPlease Enter Passcode : ");
int passcode = input.nextInt();
//find the passcode in the array
for (int i = 0;i <accountPasscode.length;i++){
if (accountPasscode[i] == passcode ){
found = 1;
index = i;
break;
}//end if
}//end for
if (found == 0 ){
System.out.println("Not found Try again");
loginBankMachine();
}//end if
}//end loginATM
public static void showAlternativeOptions(){//start ShowAlternativeOption Method
System.out.println(" Please select one of the following options available");
//give the user the menu
System.out.print("\n1.View Bank Machine Produced Statment \n2.Deposit credits\n3.Withdraw credits\n4.Change Passcode\n5.Exit");//user options
String option =input.next();//string option
switch(option){//start switch method
case "1":
BankMachineProducedStatement();break;//BankMachineProducedStatment option
case "2":
System.out.println(" Deposit Credits");break;//Deposit Credits option
case "3":
System.out.println(" Withdraw Credits");break;//Withdraw Credits option
case "4":
System.out.println(" Change Passcode");break;//Change Passcode option
case "5":
System.out.println(" Thank you for using our bank machine");break;//Exit option
}//end switch
}// end ShowaAlternativeOption method
public static void BankMachineProducedStatement(){//start BankMachineProducedStatement Method
System.out.println(" Bank Machine Produced Statment");//Bank Machine Produced Statment Description
System.out.println(index+"\t"+nameArray[index]+"\t"+creditsbalanceArray[index]+"\t"+passcodeArray[index]);//initalizing arrays
}//end BankMachineProducedStatement method
public static void DepositCredits(){//start DepositCredits Method
System.out.println(" Credits Total");//Credits Total Description
System.out.println(" Credit ");
System.out.println(index+"\t"+creditsbalanceArray[index]);//initalizing arrays
}//end DepositCredits method
public static void WithdrawCredits(){//start WithdrawCredits Method
System.out.println("Credits Withdrawn");//Credit Withdrawm Description
System.out.println(index+"\t"+creditsbalanceArray[index]);//index creditsbalanceArray
}//end WithdrawCredits method
public static void changePasscode(){
System.out.println("\nEnter new passcode");
String stringpasscode=input.next();
int passcodeArray=validateInput(passcode);
for(int i=0;i<passcodeArray.length;i++){
if (accountPasscode[i] == passcode){
System.out.println("passcode taken");
changePasscode();
}//end if
}//end for
}//end changePasscode Method
public static void Exit(){
System.out.println("Thank you for using our bank machine");
System.exit(0);
}//end Exit method
}
}//end classThis is the code that I have so far, the variables I used are different since I can't use the same variables as my class mates, so they're a bit odd. I still have to do the withdraw method, the passcode change method, the login method, the deposit method, loop, and errorcheck and I think that's it, if there's anything else that I missed that is in the guidelines then please correct me in the thread and give me a solution for it please. I tried solving the methods myself by putting in solutions from the internet but they don't match the guidelines and variables that I have, which causes problems that I can't fix, hopefully someone is able to fully help me so I can finish this frustrating assignment that has only cost me time and trouble.

