Professional Documents
Culture Documents
Question No. 3
Question No. 3
Scanner;
balance -= amount;
System.out.println("Withdrew $" + amount);
}
while (true) {
System.out.println("What would you like to do?");
System.out.println("1. Check balance");
System.out.println("2. Deposit money");
System.out.println("3. Withdraw money");
System.out.println("4. Exit");
switch (choice) {
case 1:
System.out.println("Your balance is $" + atm.getBalance());
break;
case 2:
System.out.println("Enter the amount you would like to deposit:");
int depositAmount = scanner.nextInt();
atm.deposit(depositAmount);
break;
case 3:
System.out.println("Enter the amount you would like to withdraw:");
int withdrawAmount = scanner.nextInt();
atm.withdraw(withdrawAmount);
break;
case 4:
System.out.println("Thank you for using our ATM machine!");
System.exit(0);
break;
default:
System.out.println("Invalid choice");
}
}
}
}