im writing this program for an assignment and im getting errors can anyone help make some suggestions? i have to have the program print out balances for saver1 and saver2 then change the percentage rate then reprint
//header definition file for savings account
#ifndef SAVINGS_ACCOUNT_H
#define SAVINGS_ACCOUNT_H
class SavingsAccount
{
public:
//data members
void calculateMonthlyInterest();
static void modifyInterestRate(double);
void printBalance();
double savingsBalance;
private:
//data members
static double annualInterestRate;
};
#include <iostream>
#include <iomanip>
#include "SavingsAccount.h"
using namespace std;
static double annualInterestRate;
double savingsBalance;
double SavingsAccount::annualInterestRate = 0.0;
void SavingsAccount::calculateMonthlyInterest()
{
savingsBalance += ((savingsBalance * annualInterestRate) / 12);
}
void printBalance()
{
cout<<savingsBalance;
}
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include "SavingsAccount.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// Instantiate two different objects of class SavingsAccount, saver1
// and saver2, with balances of $2000.00 and $3000.00, respectively.
SavingsAccount saver1(2000.00);
SavingsAccount saver2(3000.00);
// Set the annualInterestRate to 3%.
SavingsAccount::modifyInterestRate(3);
// Then calculate the monthly interest and print the new balances for
// each of the savers.
saver1.calculateMonthlyInterest();
cout<<"Saver 1 new balance is $"<<saver1.savingsBalance<<endl;
saver2.calculateMonthlyInterest();
cout<<"Saver 2 new balance is $"<<saver2.savingsBalance<<endl<<endl;
// Then set the annualInterestRate to 4%
SavingsAccount::modifyInterestRate(4);
// and calculate the next month's interest and print the new balances
// for each of the savers
saver1.calculateMonthlyInterest();
cout<<"Saver 1 new balance is $"<<saver1.savingsBalance<<endl;
saver2.calculateMonthlyInterest();
cout<<"Saver 2 new balance is $"<<saver2.savingsBalance<<endl<<endl;
return 0;
}
thanks in advance