This isn't exactly the best way to code this application but you could do something like this:
BankApp class
import java.util.Scanner;
public class BankApp {
public static int option;
public static int accountNumber, account;
public static Scanner userInput = new Scanner(System.in);
public static void main(String[] args) {
boolean flag = false;
double depositAmount = 50;
double withdrawAmount;
int accountNumber;
int password = 0;
showWelcome();
System.out.println("Please enter your account number: ");
while (userInput.hasNext()) {
accountNumber = userInput.nextInt();
account = accountNumber;
// if account number is less than 101 or greater than 103
// display error and exit
if (accountNumber < 101 | accountNumber > 103) {
System.out.println("You entered an invalid account number");
showExit();
} else {
System.out.println("Please enter your password: ");
password = userInput.nextInt();
if (accountNumber == 101 && password == 1111) {
System.out.println("Welcome account 101");
showMenu();
} else if (accountNumber == 102 && password == 2222) {
System.out.println("Welcome account 102");
showMenu();
} else if (accountNumber == 103 && password == 1111) {
System.out.println("Welcome account 103");
showMenu();
} else {
System.out
.println("You entered an invalid password for account "
+ accountNumber);
showExit();
}
}// end else
}// end while
}
public static void accountActivity() {
}
public static void showMenu() {
System.out.println("******************************");
System.out.println("* *");
System.out.println("* Please choose an option: *");
System.out.println("* *");
System.out.println("* 1. Depoait *");
System.out.println("* *");
System.out.println("* 2. Withdraw *");
System.out.println("* *");
System.out.println("* 3. Check Balance *");
System.out.println("* *");
System.out.println("* 4. Log Out *");
System.out.println("* *");
System.out.println("******************************");
option = userInput.nextInt();
System.out.println("You picked option: " + option);
// Check accountNumber and pass information over to Account class
if (account == 101) {
Account bob = new Account("Bob Jones", 1111, 100.00);
} else if (account == 102) {
Account mary = new Account("Mary Mack", 2222, 200.00);
} else if (account == 103) {
Account sally = new Account("Sally Star", 1111, 300.00);
}
}
public static void showWelcome() {
System.out.println("******************************");
System.out.println("* *");
System.out.println("* Welcome to Brandon's Bank *");
System.out.println("* *");
System.out.println("******************************");
}
public static void showExit() {
System.out.println("***************************************");
System.out.println("* *");
System.out.println("* Thank you for using Brandon's Bank *");
System.out.println("* *");
System.out.println("***************************************");
}
}
Account class
public class Account {
private String accountName;
private int password;
private double balanceAmount;
private static int accountNumberCounter = 100;
private int accountNumber;
public Account(String name, int pword, double balance) {
accountName = name;
password = pword;
balanceAmount = balance;
accountNumberCounter++;
accountNumber = accountNumberCounter;
// This shows we have brought the information over from the BankApp class
System.out.println(accountName + " " + password + " " + balanceAmount);
System.out.println("Option " + BankApp.option + " was selected.");
}
public int acctNum() {
return accountNumber;
}
public double getBalance() {
return balanceAmount;
}
public void setBalance(double balance) {
balanceAmount = balance;
}
public void withdraw(double withdrawAmount) {
if (withdrawAmount > balanceAmount) {
System.out
.println("You do not have enough money in your account, try again");
} else {
balanceAmount = balanceAmount - withdrawAmount;
}
}
public void deposit(double depositAmount) {
balanceAmount = balanceAmount + depositAmount;
}
}
As you can see, once they select an option from the menu, their information is passed over to the Account class. You can do what you wish with that information then.
Like I say, this isnt the best way to code this application so i'm sure you are going to come across problems!