Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ATM_machine {
- public static void main(String [] args) {
- int balance = 3000, withdraw, deposit;
- Scanner s = new Scanner(System.in);
- while (true) {
- System.out.println("Automated Teller");
- System.out.println("Choose 1 for Withdraw:");
- System.out.println("Choose 2 for Deposit:");
- System.out.println("Choose 3 for Check Balance:");
- System.out.println("Choose 4 to Exit");
- System.out.println("Choose the operation you'd like to perform:");
- int n = s.nextInt();
- switch(n) {
- case 1:
- System.out.println("How much would you like to withdraw?");
- withdraw = s.nextInt();
- if (balance >= withdraw) {
- balance = balance - withdraw;
- System.out.println("Obtain money below");
- {
- }
- System.out.println("Insufficient funds available");
- }
- System.out.println("");
- break;
- case 2:
- System.out.println("How much would you like to deposit?");
- deposit = s.nextInt();
- balance = balance + deposit;
- System.out.println("Deposit Successful");
- System.out.println("");
- break;
- case 3:
- System.out.println("Your Balance is:"+ balance);
- System.out.println("");
- break;
- case 4:
- System.exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement