Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ATM_machine {
  4.  
  5.     public static void main(String [] args) {
  6.         int balance = 3000, withdraw, deposit;
  7.         Scanner s = new Scanner(System.in);
  8.         while (true) {
  9.            
  10.             System.out.println("Automated Teller");
  11.             System.out.println("Choose 1 for Withdraw:");
  12.             System.out.println("Choose 2 for Deposit:");
  13.             System.out.println("Choose 3 for Check Balance:");
  14.             System.out.println("Choose 4 to Exit");
  15.             System.out.println("Choose the operation you'd like to perform:");
  16.             int n = s.nextInt();
  17.             switch(n) {
  18.            
  19.             case 1:
  20.                 System.out.println("How much would you like to withdraw?");
  21.                 withdraw = s.nextInt();
  22.                 if (balance >= withdraw) {
  23.                     balance = balance - withdraw;
  24.                     System.out.println("Obtain money below");
  25.                     {
  26.                            
  27.                     }
  28.                     System.out.println("Insufficient funds available");
  29.                 }
  30.             System.out.println("");
  31.             break;
  32.            
  33.             case 2:
  34.                 System.out.println("How much would you like to deposit?");
  35.                 deposit = s.nextInt();
  36.                 balance = balance + deposit;
  37.                 System.out.println("Deposit Successful");
  38.                 System.out.println("");
  39.             break;
  40.            
  41.             case 3:
  42.                 System.out.println("Your Balance is:"+ balance);
  43.                 System.out.println("");
  44.                 break;
  45.                
  46.             case 4:
  47.                 System.exit(0);
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement