Advertisement
mmayoub

SimpleAtm

Dec 30th, 2022
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | Software | 0 0
  1. package proj30122022;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SimpleAtm {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.         int atmMoney;
  10.         Scanner in = new Scanner(System.in);
  11.        
  12.         atmMoney = 10000;
  13.        
  14.         while (atmMoney>0) {
  15.             int cashOut;
  16.             do {
  17.                 System.out.print("How much cash you need? ");
  18.                 cashOut = in.nextInt();
  19.             } while(cashOut<=0 || cashOut>4000);
  20.            
  21.             if (atmMoney>=cashOut) {
  22.                 // Ok
  23.                 System.out.println("OK! Take your money and see you later.");
  24.                 atmMoney -= cashOut;
  25.             } else {
  26.                 // atm does not have money
  27.                 System.out.println("sorry! can not give you this amount !!!");
  28.             }
  29.         }
  30.        
  31.         System.out.println("ATM is closed! no money.");
  32.         in.close();
  33.     }
  34.  
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement