Question
I have the following code in C++ in which I included .h and .cpp files. I am getting the error I have included at the
I have the following code in C++ in which I included .h and .cpp files. I am getting the error I have included at the bottom. I can't seem to get my head around this one. I know it's staring me right in my face but could you please assist? Thanks.
using namespace std;
class BankingCalc { public: BankingCalc(); BankingCalc(float t_initialInvest, float t_monthlyDep, float t_annInterest, float t_years); float getInitInvest(); float getMonthlyDep(); float getAnnualInterest(); float getYears(); void dataInput(); void printReport(); float getMonths(); float getTotalAmt(); float getInterestAmt(); float getYearToInterest();
private: float initialInvest = 0; float monthlyDep = 0; float annInterest = 0; float years = 0; float months = 0; float totalAmt = 0; float interestAmt = 0; float yearToInterest = 0;
}; #endif
#include
using namespace std;
BankingCalc::BankingCalc() {
}
BankingCalc::BankingCalc(float t_initialInvest, float t_monthlyDep, float t_annInterest, float t_years) { initialInvest = t_annInterest; monthlyDep = t_monthlyDep; annInterest = t_annInterest; years = t_years; }
float BankingCalc::getInitInvest() { return initialInvest; }
float BankingCalc::getMonthlyDep() { return monthlyDep; }
float BankingCalc::getAnnualInterest() { return annInterest; }
float BankingCalc::getYears() { return years; }
float BankingCalc::getMonths() { return months; }
float BankingCalc::getTotalAmt() { return totalAmt; }
float BankingCalc::getInterestAmt() { return interestAmt; }
float BankingCalc::getYearToInterest() { return yearToInterest; }
void BankingCalc::dataInput() { cout << "*******************************" << endl; cout << "********* Data Input **********" << endl; cout << "Initial Investment Amount:"; cin >> initialInvest; if (initialInvest < 0) { cout << "Initial investment amount cannot be less than $0" << endl; cout << "Initial Investment Amount: $"; cin >> initialInvest; }; cout << "Monthly Deposit: $"; cin >> monthlyDep; if (monthlyDep < 0) { cout << "Initial investment amount cannot be less than $0" << endl; cout << "Montly Deposit: $"; cin >> monthlyDep; }; cout << "Annual Interest: %"; cin >> annInterest; cout << "Number of years:"; cin >> years; months = years * 12; system("PAUSE"); system("CLS"); totalAmt = initialInvest; }
void BankingCalc::printReport() { cout << " Balance and Interest Without Additional Monthly Deposits" << endl; cout << "===========================================================================" << endl; cout << " Year Year End Balance Year End Earned Interest" << endl; cout << "------------------------------------------------" << endl; for (int i = 0; i < years; i++) { interestAmt = (totalAmt) * (annInterest / 100); totalAmt = totalAmt + interestAmt; cout << " " << (i + 1) << "\t\t$" << fixed << setprecision(2) << totalAmt << "\t\t\t$" << interestAmt << " "; } totalAmt = initialInvest;
cout << endl; cout << " Balance and Interest With Additional Monthly Deposits" << endl; cout << "===========================================================================" << endl; cout << " Year Year End Balance Year End Earned Interest" << endl; cout << "------------------------------------------------" << endl;
for (int i = 0; i < years; i++) { yearToInterest = 0;
for (int j = 0; j < 12; j++) { interestAmt = (totalAmt + monthlyDep) * ((annInterest / 100) / 12); yearToInterest = yearToInterest + interestAmt; totalAmt = totalAmt + monthlyDep + interestAmt; } cout << (i + 1) << "\t\t$" << fixed << setprecision(2) << totalAmt << "\t\t\t$" << yearToInterest << " "; } }
Severity Code Description Project File Line Suppression State Error (active) E0036 the #if for this directive is missing AirgeadBanking U:\AirgeadBanking\AirgeadBanking\BankingCalc.h 30 Severity Code Description Project File Line Suppression State Error C1020 unexpected #endif AirgeadBanking U:\AirgeadBanking\AirgeadBanking\BankingCalc.h 30
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started