#include <iostream>
usingnamespace std;
class SavingsAccount
{
public:
SavingsAccount(){}
SavingsAccount(int value);
~SavingsAccount(){}
staticfloat annualInterestRate;
void calculateMonthlyInterest();
staticvoid modifyIntererestRate(float value);
float GetBalance() const { return savingsBalance; }
private:
// Each member of the class contains a private data member
// savingsBalance indicating the amount the saver currently has
// on deposit.
float savingsBalance;
};
// copy constructor to initialize the value at instantiation
SavingsAccount::SavingsAccount(int value)
{
savingsBalance = value;
}
// Use a static data member annualInterestRate to store the annual interest
// rate for each of the savers.
float SavingsAccount::annualInterestRate = 0;
// Provide member function calculateMonthlyInterest that calculates the
// monthly interest by multiplying the savingsBalance by annualInterestRate
// divided by 12 and then adds this interest to savingsBalance.
void SavingsAccount::calculateMonthlyInterest()
{
savingsBalance += ((savingsBalance * annualInterestRate) / 12);
}
//Provide a static member function modifyIntererestRate that sets the
// static annualInterestRate to a new value.
void SavingsAccount::modifyIntererestRate(float value)
{
annualInterestRate = value;
}
int main()
{
// 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::modifyIntererestRate(3);
// Then calculate the monthly interest and print the new balances for
// each of the savers.
saver1.calculateMonthlyInterest();
cout << "Saver 1 Savings Balance: $" << saver1.GetBalance() << endl;
saver2.calculateMonthlyInterest();
cout << "Saver 2 Savings Balance: $" << saver2.GetBalance() << endl;
cout << endl;
// Then set the annualInterestRate to 4%
SavingsAccount::modifyIntererestRate(4);
// and calculate the next month's interest and print the new balances
// for each of the savers
saver1.calculateMonthlyInterest();
cout << "Saver 1 Savings Balance: $" << saver1.GetBalance() << endl;
saver2.calculateMonthlyInterest();
cout << "Saver 2 Savings Balance: $" << saver2.GetBalance() << endl;
cout << endl;
return 0;
{
public:
SavingsAccount(){}
SavingsAccount(double value);
~SavingsAccount(){}
staticfloat annualInterestRate;
void calculateMonthlyInterest();
staticvoid modifyIntererestRate(float value);
float GetBalance() const { return savingsBalance; }
private:
// Each member of the class contains a private data member
// savingsBalance indicating the amount the saver currently has
// on deposit.
float savingsBalance;
};
#endif
//function definition for SavingsAccount class
#include "savingsAccount.h"
// copy constructor to initialize the value at instantiation
SavingsAccount::SavingsAccount(double value)
{
savingsBalance = value;
}
// Use a static data member annualInterestRate to store the annual interest
// rate for each of the savers.
float SavingsAccount::annualInterestRate = 0;
// Provide member function calculateMonthlyInterest that calculates the
// monthly interest by multiplying the savingsBalance by annualInterestRate
// divided by 12 and then adds this interest to savingsBalance.
void SavingsAccount::calculateMonthlyInterest()
{
savingsBalance += ((savingsBalance * annualInterestRate) / 12);
}
//Provide a static member function modifyIntererestRate that sets the
// static annualInterestRate to a new value.
void SavingsAccount::modifyIntererestRate(float value)
{
annualInterestRate = value;
}
#include <cstdlib>
#include <iostream>
#include "savingsAccount.h"
usingnamespace std;
int main(int argc, char *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::modifyIntererestRate(3);
cout << "Saver 1 Savings Balance: $" << saver1.GetBalance() << endl;
cout << "Saver 2 Savings Balance: $" << saver2.GetBalance() << endl;
cout << endl;
// Then calculate the monthly interest and print the new balances for
// each of the savers.
saver1.calculateMonthlyInterest();
cout << "Saver 1 Savings Balance: $" << saver1.GetBalance() << endl;
saver2.calculateMonthlyInterest();
cout << "Saver 2 Savings Balance: $" << saver2.GetBalance() << endl;
cout << endl;
// Then set the annualInterestRate to 4%
SavingsAccount::modifyIntererestRate(4);
// and calculate the next month's interest and print the new balances
// for each of the savers
saver1.calculateMonthlyInterest();
cout << "Saver 1 Savings Balance: $" << saver1.GetBalance() << endl;
saver2.calculateMonthlyInterest();
cout << "Saver 2 Savings Balance: $" << saver2.GetBalance() << endl;
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
The error message basically says that you misspelled "#include" (you wrote "#inclue"). The typo is probably in the first few lines of savingsAccount.h that you neglected to show.
Random Note:
Your constructor takes in a double as a parameter, but your data member is a float, so you will lose precision in the conversion. Be consistent with your data types.