Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Menu extends Account {
- Scanner myScan = new Scanner(System.in);
- public void displayMenu() {
- System.out.println("Please select one of the choices below");
- System.out.println("1 - Balance Check");
- System.out.println("2 - Deposit Money");
- System.out.println("3 - Withdraw Money");
- System.out.println("4 - Exit");
- System.out.print("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:
- displayBalance();
- returnToMenu();
- break;
- case 2:
- addBalance();
- returnToMenu();
- break;
- case 3:
- System.out.println("Please Enter the Withdraw Amount");
- returnToMenu();
- case 4:
- goodBye();
- }
- }
- public double displayBalance() {
- System.out.print("You Current Account Balance:$");
- System.out.println(accountBalance);
- return accountBalance;
- }
- public void addBalance() {
- System.out.print("Please Enter The Amount to Deposit:");
- setAccountBalance(Double.parseDouble(myScan.next()));
- System.out.printf("Your new account balance is:$%.2f\n", accountBalance);
- System.out.println();
- }
- public void goodBye() {
- System.out.println("Goodbye - and have a nice day");
- System.exit(0);
- }
- public void returnToMenu() {
- 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) {
- displayMenu();
- } else {
- goodBye();
- }
- }
- }
Add Comment
Please, Sign In to add comment