Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.IOException;
- import java.util.Scanner;
- public class Menu extends Account {
- Scanner myScan = new Scanner(System.in);
- public void menuGreeting() {
- System.out.println("ATM Welcome Message");
- }
- public void menuPrint() throws IOException {
- menuGreeting();
- System.out.println("Please enter one of the following choices");
- System.out.println("1 - Display Balance");
- System.out.println("2 - Deposit Money");
- System.out.println("3 - Withdraw Money");
- System.out.println("4 - Exit");
- System.out.print("Enter Your Choice: ");
- int choice = myScan.nextInt();
- while (choice > 4) {
- System.out.println("Wrong choice, please select 1-4 ");
- System.out.print("Choice:");
- choice = myScan.nextInt();
- } switch (choice) {
- case 1:
- System.out.println("Display Balance Menu");
- menuBalance();
- returnMenu();
- break;
- case 2:
- System.out.println("Deposit Money Menu");
- menuBalance();
- setBalance();
- returnMenu();
- break;
- case 3:
- System.out.println("Withdraw Money Menu");
- returnMenu();
- break;
- case 4:
- exitProgram();
- }
- }
- public void menuBalance() {
- System.out.print("Your Current Balance is: $");
- System.out.println(getBalance());
- }
- public void menuDeposit() {
- }
- public void menuWithdraw() {
- }
- public void exitProgram() {
- System.out.println("Goodbye - Have a nice day");
- System.exit(0);
- }
- private void returnMenu() throws IOException {
- System.out.println("To return in the main menu press 0");
- System.out.println("To exit press 1");
- System.out.print("Choice:");
- int menuChoice = myScan.nextInt();
- if (menuChoice == 0) {
- menuPrint();
- } else {
- exitProgram();
- }
- }
- }
Add Comment
Please, Sign In to add comment