Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exercise_3;
- import java.util.Scanner;
- public class Task_1 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int balance = 1000, withdraw;
- System.out.printf("Your current balance is %d SEK %n", balance);
- System.out.println("How much money would you like to withdraw?");
- withdraw = input.nextInt();
- if (withdraw > balance || withdraw < 0) {
- System.out.println("Invalid amount. Amount must be >= 0 and <= balance");
- }
- else {
- if (withdraw % 100 != 0) {
- System.out.println("You can only withdraw 100 SEK bills.");
- }
- else {
- balance = balance - withdraw;
- System.out.printf("Your new balance is %d SEK %n", balance);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment