May anyone please help me with this:
(I am new to c++)
Create a SavingsAccount class. Use a static data member to contain the annualInterestRate for each of the savers. Each member of the class contains a private data member savingsBalance indicating the amount the saver currently has on deposit. Provide a calculateMonthlyInterest member function that calculates the monthly interest by multiplying the balance by annualInterestRate divided by 12; this interest should be added to savingsBalance. Provide a static member function modifyInterestRate that sets the static annualInterestRate to a new value. Write a driver program to test class SavingsAccount. Instantiate two different savingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 3%, then calculate the monthly interest and print the new balances for each of the savers. Then set the annualInterestRate to 4% and calculate the next month's interest and print the new balances for each of the savers.
Here is what I got so far:
SavingAccount.h
************
#pragma once
class CSavingsAccount
{
private:
float savingsBalance;
public:
CSavingsAccount( );
~CSavingsAccount();
static float annualInterestRate;
float calculateMonthlyInterest();
static float ModifyInterestRate();
};
savingAccount.ccp
**************
#include "StdAfx.h"
#include ".\savingaccount.h"
CSavingsAccount::CSavingsAccount()//Constructor
{
}
CSavingsAccount::~CSavingsAccount()//Destructor
{
}
float CSavingsAccount::calculateMonthlyInterest()
{
return 0;
}
float CSavingsAccount::ModifyInterestRate()
{
return 0;
}
Main
****
#include "stdafx.h"
#include ".\savingaccount.h"//header file
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
CSavingsAccount saving1;
CSavingsAccount saving2;
cout<<"Balance for saving1 is: "
<<saving1.calculateMonthlyInterest()<<endl;
cout<<"Balance for saving2 is: "
<<saving2.calculateMonthlyInterest()<<endl;
cout<<" \n"<<endl;
cout<<"New balance for saving1 is: "
<<saving1.ModifyInterestRate()<<endl;
cout<<"New balance for saving2 is: "
<<saving2.ModifyInterestRate()<<endl;
system("pause");
return 0;
}