ATM - /* class ATM * Author: Diana Franklin Purpose:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* class ATM * Author: Diana Franklin Purpose: Implement an ATM. */ import java.util.Scanner; public class ATM { public static void main(String args[]) { BankAccount acct; boolean overdrawn; Scanner input= new Scanner( System.in ); int option, amount; acct = new BankAccount();// create one bank account option = 0; // make sure we loop at least once // print out a welcome message System.out.println("Welcome to the ATM"); // keep session going until user says to exit while (option != 3) { // first give user options, then ask what user wants // to do System.out.println("Check Balance: 0\n Deposit: 1"); System.out.println("Withdrawal: 2\n Exit: 3"); System.out.print("What would you like to do next? "); option = input.nextInt(); if (option == 0) { System.out.printf("Your balance is %d\n", acct.getBalance()); } else if (option == 1) { System.out.print("How much would you like to deposit? "); // get amount to deposit from user amount = input.nextInt(); acct.deposit(amount); // make the deposit
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

ATM - /* class ATM * Author: Diana Franklin Purpose:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online