I am fairly new to JAVA, but I am working on a program and this is the issue im running into, might be a simple fix.
I prompt the user to enter their ID for a mock ATM system.
{
System.out.println("Enter an ID: ");
Scanner input = new Scanner(System.in);
String acctID = input.next();
withdrawAccount(acctID);
System.out.println(IDnum.getBalance());
}
There is more to the code but it is irrelevant at this time. There will be several if statements to see what action the user wants to do, i.e. withdraw money from their account. In this program I want to have the user enter there ID and save it as a string and pass it to WithdrawAccount method. So acctID would reference what ever the user enters for the account ID. Note the account ID is the same as the name of the Account variable. so Account 0 will have an ID of 0.
public static void withdrawAccount(String acctID)
{
System.out.println("Enter Withdraw Amount: ");
Scanner input = new Scanner(System.in);
double WithdrawAmount = input.nextDouble();
acctID.setBalance(acctID.getBalance() - WithdrawAmount);
}
Account(or the class you have) object which account id is theStringthe user typed. This looks more like a design issue.