Problem with the program, \" \'modifyInterestRate\' : redefinition; multiple ini
ID: 3574213 • Letter: P
Question
Problem with the program, " 'modifyInterestRate' : redefinition; multiple initialization, Please help me fix thank you!
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class savingsAccount
{
private:
static double annualInterestRate; // static = shared, only one instance
double accountBalance;
public:
savingsAccount();
savingsAccount(double);
void setAnnualInterestRate(double);//declare your constructor
void setaccountBalance(double);
double getAnnualInterestRate(double);// declare your overloaded constructor
double getaccountBalance(double);
void calculateMonthlyInterest();
static void modifyInterestRate(double newInterestRate);
};
void savingsAccount::setAnnualInterestRate(double annual)
{
annualInterestRate = annual;
}
void savingsAccount::setaccountBalance(double balance)
{
accountBalance= balance;
}
double savingsAccount::getAnnualInterestRate(double)
{
return annualInterestRate;
}
double savingsAccount::getaccountBalance(double)
{
return accountBalance;
}
void savingsAccount::calculateMonthlyInterest()
{
accountBalance = ((accountBalance * annualInterestRate) / 12) + accountBalance;
}
savingsAccount::savingsAccount(double balance)
{
accountBalance = balance;
}
int main()
{
savingsAccount savings1(2000.00);
savingsAccount savings2(3000.00);
savingsAccount savings3(4000.00);
savingsAccount modifyInterestRate(0.03);
savings1.calculateMonthlyInterest();
cout << "savings1 account balance is" <<savings1.getaccountBalance(2000.00) << endl;
savings2.calculateMonthlyInterest();
cout << "savings2 account balance is" <<savings2.getaccountBalance(3000.00) << endl;
savings3.calculateMonthlyInterest();
cout << "savings3 account balance is" <<savings3.getaccountBalance(4000.00) << endl;
savingsAccount modifyInterestRate(0.03); <<<< << <<-------------------------------------------------------------------------------------------------------------------------------------------------THIS LINE!!
savings1.calculateMonthlyInterest();
cout << "savings1 account balance is" << savings1.getaccountBalance(2000.00) << endl;
savings2.calculateMonthlyInterest();
cout << "savings2 account balance is" << savings2.getaccountBalance(3000.00) << endl;
savings3.calculateMonthlyInterest();
cout << "savings3 account balance is" << savings3.getaccountBalance(4000.00) << endl;
system("Pause");
return 0;
}
Explanation / Answer
You had defined mofifyInterrestRate as static. so you cant use it ,multiple times. and you has defined ot. but had not write any thing about that method. Modify your program as this
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.