I\'m writing a C++ program using a class model: - balance: double - interestRate
ID: 641778 • Letter: I
Question
I'm writing a C++ program using a class model:
- balance: double
- interestRate: double
- interest: double
- transactions: integer
+ setInterestRate (double ): void
+ makeDeposit(double): void
+ withdraw(double ): bool
+ calcInterest( ): void
+ getInterestRate( ): double const
+ getBalance( ): double const
+ getInterest( ): double const
+ getTransactions( ): double const
I have the header file down, but I'm not even sure where to start for the definition part. Once I get that the testing part will be easy. Can anyone help me with the definition?
Explanation / Answer
class BankDetails
{
private double balance;
private double interestRate
private double interest;
private Int transactions;
public void setInterestRate (double rate )
{ interestRate=rate; }
public void makeDeposit(double deposit)
{ balance=balance+deposit;
transaction++; }
public boolean withdraw(double amount)
{ balance=balance-amount;
transaction++;
return true; }
public void calcInterest( )
{ interest=balance*interestRate*1/100; }
public double getInterestRate( )
{ return interestRate; }
public double getBalance( )
{ return balance; }
public double getInterest( )
{return interest; }
public double getTransactions( )
{return transaction;}
}