Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package proj30122022;
- import java.util.Scanner;
- public class SimpleAtm {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int atmMoney;
- Scanner in = new Scanner(System.in);
- atmMoney = 10000;
- while (atmMoney>0) {
- int cashOut;
- do {
- System.out.print("How much cash you need? ");
- cashOut = in.nextInt();
- } while(cashOut<=0 || cashOut>4000);
- if (atmMoney>=cashOut) {
- // Ok
- System.out.println("OK! Take your money and see you later.");
- atmMoney -= cashOut;
- } else {
- // atm does not have money
- System.out.println("sorry! can not give you this amount !!!");
- }
- }
- System.out.println("ATM is closed! no money.");
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement