In class we talked about the bank account class described below:
//*****************************************************
// Account.java
//
// A class representing a bank account; allows deposits,
// withdrawals, balance inquiries, etc.
//*****************************************************
public class Account
{
private double balance;
private String name;
private long acctNum;
//---------------------------------------------------
// Constructor -- initializes instance data
//---------------------------------------------------
public Account(double initBal, String owner, long number)
{
balance = initBal;
name = owner;
acctNum = number;
}
//---------------------------------------------------
// Simple withdrawal -- deducts amount from balance
//---------------------------------------------------
public void withdraw(double amount)
{
balance -= amount;
}
//---------------------------------------------------
// Simple deposit -- adds amount to balance.
//---------------------------------------------------
public void deposit(double amount)
{
balance += amount;
}
//---------------------------------------------------
// Returns balance.
//---------------------------------------------------
public double getBalance()
{
return balance;
}
//---------------------------------------------------
// Prints name, account number, and balance
//---------------------------------------------------
public void printSummary()
{
//print name
_____________________________
//print acct number
_____________________________
//print balance
_____________________________
}
//---------------------------
// Deducts $10 service fee
//---------------------------
public double chargeFee()
{
// deduct the fee
____________________________________________________
// return the updated balance
____________________________________________________
}
//---------------------------------------------------
// Changes the name on the account to newName.
//---------------------------------------------------
public void changeName(String newName)
{
___________________________________________________
}
}
- Fill in the code for method printSummary, which should
print the name, account number, and balance for the account.
- Fill in the code for method chargeFee,
which should deduct a service fee of $10 from the account,
and then return the balance.
- In the last space, fill in the body for method changeName
that takes a string
as a parameter
and changes the name on the account to be that string.