Stelios_Gakis

Exercise_3/Task_1

Sep 14th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package Exercise_3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task_1 {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         int balance = 1000, withdraw;
  10.  
  11.         System.out.printf("Your current balance is %d SEK %n", balance);
  12.         System.out.println("How much money would you like to withdraw?");
  13.         withdraw = input.nextInt();
  14.         if (withdraw > balance || withdraw < 0) {
  15.             System.out.println("Invalid amount. Amount must be >= 0 and <= balance");
  16.         }
  17.         else {
  18.             if (withdraw % 100 != 0) {
  19.                 System.out.println("You can only withdraw 100 SEK bills.");
  20.             }
  21.             else {
  22.                 balance = balance - withdraw;
  23.                 System.out.printf("Your new balance is %d SEK %n", balance);
  24.             }
  25.         }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment