Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ATMSimulation copy-java x 2 Simulates a simple ATM. The user can check his/her balance, 3 deposit money, and withdraw money 5 import java.util.Scanner 7 public

image text in transcribed
image text in transcribed
ATMSimulation copy-java x 2 Simulates a simple ATM. The user can check his/her balance, 3 deposit money, and withdraw money 5 import java.util.Scanner 7 public class Govtservice 8 public static void main(String[] args)t Scanner scnr new Scanner(System.in); 10 // Show the ATM menu System.out.println("ATM") System.out.println("1. Check balance" 12 13 14 15 16 17 18 19 20 21 Systen.out.printunt"3. System.out.printni Withdraw money.); // This variable stores the amount of money in the account double bal 1.20; // a realistic college student amount /I Get user input for his/her choice System.out.print ln("Enter the number of your choice:")i int choice scnr.nextInt); 23 24 25 26 if (choice 1) // Check balance System.out.print In("Current balance: " +bal): 28 else if (choice 2) I // Deposit money 30 31 32 System.out.println("How much?") double deposit scnr.nextDouble): bal deposit; System.out.print In("New balance: " +bau 34 else if (choice 3) (Withdraw money System.out.print In("How much?") double withdraw scnr.nextDouble); bal-withdraw 38 39 40 41 42 System.out.printIn("New balance: $" ba)i When provided at the end of a multibranch conditional, else // gives the program something to do if *none* of the preceding II conditions are true. Here, we use it to detect invalid choices I1 (i.e., anything besides 1, 2, or 3). else t 45 46 47 48 49 50 51 System.out.print ln("Lrn2read.") Modify ATMSimulation.java to include an exit option in the main menu, and add a loop that allows the user to repeatedly interact with the program until s/he chooses to exit. This is more realistic - the user can now check his/her balance and deposit/withdraw funds without having to restart the program! Much amaze. Wow. Caution: Take care not to reset the balance in the account every time the loop repeats

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago