A savings account that extends BankAccount with interest rate functionality and minimum balance requirements.
Usage
SavingsAccount(
account_number = "",
account_holder = "",
initial_balance = 0,
interest_rate = 0.02,
min_balance = 100
)
Arguments
- account_number
character. Unique identifier for the account.
- account_holder
character. Name of the account holder.
- initial_balance
numeric. Initial account balance (must meet minimum balance requirement).
- interest_rate
numeric. Annual interest rate (between 0 and 1).
- min_balance
numeric. Minimum balance required to maintain the account.
Fields
interest_rate
numeric. Annual interest rate (between 0 and 1).
min_balance
numeric. Minimum balance required to maintain the account.
Examples
# Create a savings account with 3% interest rate and $100 minimum balance
savings <- SavingsAccount("SAV123", "John Doe", 1000,
interest_rate = 0.03, min_balance = 100)
# Add interest
add_interest(savings)
#> Interest added: $30.00 (3.0%). New balance: $1030.00
# Attempt withdrawal (respects minimum balance)
withdraw(savings, 500)
#> Withdrew $500.00 from savings account. New balance: $500.00