content: package gr.aueb.cf.ch8;
  
  import java.time.LocalDateTime;
  import java.util.Scanner;
  
  public class Exception11SimpleBank8 {
      static double balance = 500;
      static Scanner in = new Scanner(System.in);
  
      public static void main(String[] args)  {
          try {
              deposit(100);
          } catch (Exception e) {
              System.out.println("An error happened. Try again...");
          }
      }
  
      public static void deposit(double amount) throws Exception {
          try {
              if (amount <= 0) {
                  throw new Exception("Amount must be positive.");
              }
              balance += amount;
              System.out.println("Successfully deposited: " + amount);    // log
          } catch (Exception e) {
              System.err.println(LocalDateTime.now() + "\tdeposit\n" + e);  // log
              throw e;
          }
      }
  
      public static void withdraw(double amount) throws Exception {
          try {
              if (amount <= 0) {
                  throw new Exception("Amount must be positive.");
              }
              if (amount > balance) {
                  throw new IllegalArgumentException("Amount must be less than balance.");
              }
              balance -= amount;
              System.out.println("Successfully withdrawn: " + amount);    // log
          } catch (Exception e) {
              System.err.println("Error. " + e.getMessage());             // log
              throw e;
          }
      }
  }
  