import java.util.Scanner; class Account { private String accountNumber; private double balance; // Constructor to initialize account number and balance public Account(String accountNumber, double balance) { this.accountNumber = accountNumber; this.balance = balance; } // Withdraw method that throws IllegalArgumentException for invalid amounts public void withdraw(double amount) throws IllegalArgumentException { if (amount > balance) { throw new IllegalArgumentException("Insufficient funds for this transaction."); } if (amount < 0) { throw new IllegalArgumentException("Withdrawal amount cannot be negative."); } balance -= amount; System.out.println("Withdrawal successful. New balance: " + balance); } } public class Main { public static void main(String[] args) { // Creating an instance of Account with a sample account number and balance Account account = new Account("123456789", 1000.00); Scanner scanner = new Scanner(System.in); System.out.print("Enter the amount to withdraw: "); try { double amount = scanner.nextDouble(); account.withdraw(amount); } catch (IllegalArgumentException e) { System.out.println("Error: " + e.getMessage()); } finally { scanner.close(); } } }