The assignment is to design a savings account program.
The program has to include: a constructor that accepts an argument of type double and uses it to set savingsBalance. If the value is passed is less than 0, set savingsBalance to 0.
Add a public member function named calaculateMonthlyInterest that accepts no argument and returns nothing.
Add a public member function named modifyInterestRate that accepts a single argument of type double and returns nothing. Declared the function as static.
The errors that I have are:
error C2228: left of '.print' must have class/struct/union
error C2511: 'void Savings_Account::modifyInterestRate(double)' : overloaded member function not found in 'Savings_Account'
error C2065: 'aI' : undeclared identifier
error C2662: 'Savings_Account::calculateMonthylyInterest' : cannot convert 'this' pointer from 'const Savings_Account' to 'Savings_Account &'
#ifndef SAVINGS_ACCOUNT_H
#define SAVINGS_ACCOUNT_H
class Savings_Account
{
public:
//constructor
Savings_Account(double s = 0)
{
setsavingsBalance(s);
}
void setsavingsBalance(double);
double getsavingsBalance();
double calculateMonthylyInterest();
static double modifyInterestRate();
double print() const;
private:
double savingsBalance;
static double annualInterestRate;
//double customerInput;
};
#endif
#include "stdafx.h"
#include "Savings_Account.h"
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
//Savings_Account::Savings_Account(double savingsBalance, double annualInterestRate)
//{
// setsavingsBalance(savingsBalance)
//}
void Savings_Account::setsavingsBalance(double s)
{
if(savingsBalance > 0)
{
savingsBalance = s;
}
else
savingsBalance = 0;
}
double Savings_Account::getsavingsBalance()
{
return savingsBalance;
}
void Savings_Account::modifyInterestRate(double aI)
{
if(aI > 0 && aI <1)
{
annuallyInterestRate = aI;
}
else
annuallyInterestRate =0.03;
}
double Savings_Account::annualInterestRate = 0;
double Savings_Account::calculateMonthylyInterest()
{
double customerSavingsBal;
cout << "Please enter your savings balance: ";
cin >> savingsBalance;
customerSavingsBal= savingsBalance * aI;
}
double Savings_Account::print() const
{
cout << "Your savings account balance is: " << calculateMonthylyInterest() << endl;
}
// lab1.1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Savings_Account.h"
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
//Savings_Account object
Savings_Account savingsAccount;
//prompt customer for savings balance and print the balance out
savingsAccount.calculateMonthylyInterest().print();
return 0;
}