hi, i just made an account to ask this question. i need help FAST. this is due at midnight
testbankaccount.cpp(38) : error C2228: left of '.getBalance' must have class/struct/union
Code:
// #pragma once#include <iostream>
using namespace std;
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
class BankAccount
{
private:
double balance; // holds the current account balance
double interestRate; // holds the interest rate for the current period
double interest; // holds the interest earned for the current period
int numTransactions; // holds the current number of transactions
public:
BankAccount();
void setInterestRate(double);
void makeDeposit(double);
bool makeWithdraw(double);
void computeInterest();
double getInterestRate();
double getBalance();
double getInterest();
int getNumTransactions();
};
#endif
Code:
#include <iostream>#include "BankAccount.h"
using namespace std;
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
BankAccount::BankAccount()
{
balance = 0;
interestRate = 0.056;
interest = 0;
numTransactions = 0;
}
void BankAccount::setInterestRate(double interestRate)
{
this->interestRate = interestRate;
}
void BankAccount::makeDeposit(double deposit)
{
balance += deposit;
numTransactions++;
}
bool BankAccount::makeWithdraw(double withdraw)
{
if (balance < withdraw)
return false;
else
{
balance -= withdraw;
numTransactions++;
return true;
}
}
void BankAccount::computeInterest()
{
interest = interestRate(balance);
balance += interest;
}
double BankAccount::getInterestRate()
{
return interestRate;
}
double BankAccount::getBalance()
{
return balance;
}
double BankAccount::getInterest()
{
return interest;
}
int BankAccount::getNumTransactions()
{
return numTransactions;
}
int main()
{
return 0;
}
#endif
Code:
#include <iostream>#include "BankAccount.h"
using namespace std;
void heading();
void displayMenu();
void makeDeposit(BankAccount &depositAmount);
void makeWithdraw(BankAccount &withdrawAmount);
int main()
{
heading();
cout << endl;
displayMenu();
BankAccount savings;
int userChoice;
cin >> userChoice;
for (userChoice; userChoice > 6;)
{
cout << endl;
cout << "There is no option " << userChoice << ". Please choose a task that is listed." << endl;
cout << endl;
displayMenu();
cin >> userChoice;
}
if (userChoice == 6)
{
cout << endl;
cout << "Thank you. Please wait." << endl;
cout << endl;
cout << "Thank you for being a loyal customer!" << endl;
cout << endl;
}
/*if (userChoice == 1)
{
BankAccount::makeDeposit(savings);
}
if (userChoice == 2)
{
BankAccount::makeWithdraw(savings);
}
if (userChoice == 3)
{
savings.getBalance();
}
if (userChoice == 4)
{
savings.getNumTransactions();
}
if (userChoice == 5)
{
savings.getInterest();
}*/
}
void heading()
{
cout << "/********************************************************************************************" << endl;
cout << "* Course Name: CMPS 191 – Modular Programming and Algorithms Development II" << endl;
cout << "* Project 2" << endl;
cout << "* Section: 01" << endl;
cout << "* Semester: Spring 2013" << endl;
cout << "*" << endl;
cout << "* Project Members:" << endl;
cout << "* Leader: William R. Veal III" << endl;
cout << "*" << endl;
cout << "*" << endl;
cout << "* Instructor: Dr. Mathieu Kourouma" << endl;
cout << "*" << endl;
cout << "* Description:" << endl;
cout << "* Provide here a brief description of the purpose of the project" << endl;
cout << "*" << endl;
cout << "* Due Date: Wednesday, March 26, 2013 by 11:59 PM on Blackboard" << endl;
cout << "*" << endl;
cout << "* Certificate of Authentication:" << endl;
cout << "*" << endl;
cout << "* We, the listed group members:" << endl;
cout << "* Claim that this project’s work fully our own work." << endl;
cout << "* We wrote this program independently." << endl;
cout << "* We did not copy any part of the code from other group members." << endl;
cout << "* We did not share at all our codes with other group members." << endl;
cout << "* We are only allowed to seek help from the instructor of this course and group members" << endl;
cout << "*" << endl;
cout << "* Signature: WRVIII" << endl;
cout << "*" << endl;
cout << "**********************************************************************************************/" << endl;
}
void displayMenu()
{
cout << "----------------------------------------------------------------------------------------------------------------------------------" << endl;
cout << " Welcome to SUBR's Credit Union Banking System" << endl;
cout << "-----------------------------------------------------------------------------------------------------------------------------------" << endl;
cout << "" << endl;
cout << "Please select from the following menu:" << endl;
cout << " " << endl;
cout << "1. Make a deposit" << endl;
cout << "2. Make a withdraw" << endl;
cout << "3. Display account balance" << endl;
cout << "4. Display the number of transactions" << endl;
cout << "5. Display interest earned " << endl;
cout << "6. Exit the banking system" << endl;
cout << " " << endl;
cout << "Make your selection: ";
}
void makeDeposit(BankAccount &depositAmount)
{
double deposit;
cout << "Enter the amount you wish to deposit: ";
cin >> deposit;
cout << endl;
depositAmount.makeDeposit(deposit);
cout << "Your deposit is " << deposit << endl;
}
void makeWithdraw(BankAccount &withdrawAmount)
{
double withdraw;
cout << "Enter the amount you wish to withdraw: ";
cin >> withdraw;
if (!withdrawAmount.makeWithdraw(withdraw))
cout << "The amount you want to withraw is larger than the balance." << endl;
}