Question
I need UML for my code please import java.util.Scanner; public class atm { static Scanner input = new Scanner(System.in); public static void main(String args[] )
I need UML for my code please
import java.util.Scanner;
public class atm { static Scanner input = new Scanner(System.in); public static void main(String args[] ) { int balance = 5000; //simulating the ATM while(true) { //show the available possible options showMenu(); int n = input.nextInt(); switch(n) { case 1: //withdraw from ATM balance = withdrawMoney(balance); break;
case 2: //balance check System.out.println("Available Balance: $"+balance); break; case 4: input.close(); System.exit(0); default: System.out.println("Invalid selection. Please try again!!"); } System.out.println(" "); } }
/** * Method to show the possible options in the menu */ private static void showMenu() { System.out.println("atm test"); System.out.println("Enter 1 to Withdraw Money, and 2 Check Balance"); System.out.print("Enter your choice: "); } /** Method to withdraw the amount */ private static int withdrawMoney(int balance) { System.out.print("Enter money to be withdrawn: $"); int withdraw = input.nextInt(); //check sufficient balance available if(balance >= withdraw) { balance -= withdraw; System.out.println("Please collect your money"); } else System.out.println("Insufficient Balance"); return balance; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started