public class BankAccount
{
private double balance;
public BankAccount()
{
balance = 0.0;
}
public BankAccount(double initialAmount) {
balance = initialAmount;
}
public void deposit(double amount)
{
balance += amount;
}
public double getBalance()
{
return balance;
}
public void withdraw(double amount) {
if (balance >= amount) {
balance -= amount;
} else {
throw new IllegalArgumentException("Insufficent funds");
}
}
public String toString()
{
return String.format("BankAccount(balance = %.2f)", balance);
}
}