Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The BankAccountMain.cpp can't be changed cause of assignment restrictions.

I'm getting error C2039: 'setInterestRate' : is not a member of 'SavingsAccount' and error C2039: 'getNumberOfDays' : is not a member of 'SavingsAccount'

Here is my codes for the 2 files that are showing up

BankAccountMain.cpp

C++
#include "BankAccount.h"
#include "CheckingAccount.h"
#include "SavingsAccount.h"
#include <iostream>
#include <iomanip>
#include <windows.h>

using namespace std;

void main(void)
{
int i = 0;
int newAccountNumber = 0;
double depositAmount = 0.0;
double withdrawAmount = 0.0;
double newInterestRate = 0.0;

srand(GetTickCount()); //Seed the random number generator
////////////////////////////////////////////////////////////////////////

//Saving account Test;

CheckingAccount account1;
SavingsAccount account2;

cout << "Enter a six digit integer for your new savings account number: ";
cin >> newAccountNumber;
account2.setAccountNumber(newAccountNumber);
cout << endl;

cout << "Retrieving new savings account number" << endl;
cout << "New Savings Account Number: " << account2.getAccountNumber() << endl << endl;

cout << "Set savings account interest rate" << endl;
cin >> newInterestRate;
account2.setInterestRate(newInterestRate);

cout << "Savings account balance for account # " << account2.getAccountNumber() <<
" is $" << account2.getAccountBalance() << endl << endl;
cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;

cout << showpoint << fixed << setprecision(2);

account2.depositMoney(100.0);
cout << "Savings account balance for account # " << account2.getAccountNumber() << " is $" << account2.getAccountBalance() << endl; // FIXED CODE
cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;

for(i = 0; i < 10; i++)
{
cout << "Withdraw money from savings account" << endl;
if(account2.withdrawMoney(20.0) == false)
cout << "Withdrawal denied, insufficient funds" << endl;

cout << "Savings account balance for account # " << account2.getAccountNumber() <<
" is $" << account2.getAccountBalance() << endl;

cout << "Total interest earned: " << account2.getInterestEarned() << " over " << account2.getNumberOfDays()
<< " days" << endl << endl;
}

////////////////////////////////////////////////////////////////////////
// Checking Account Test

cout << "Enter a six digit integer for your new account number: ";
cin >> newAccountNumber;
account1.setAccountNumber(newAccountNumber);
cout << endl;

cout << "Retrieving new checking account number" << endl;
cout << "New Checking Account Number: " << account1.getAccountNumber() << endl << endl;

cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;

cout << showpoint << fixed << setprecision(2);

account1.depositMoney(100.0);
cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;

for(i = 0; i < 10; i++)
{
cout << "Withdraw money from checking account" << endl;
if(account1.withdrawMoney(20.0))
cout << "Monthly free transactions exceeded, $0.50 charge deducted from account" << endl << endl;
else
cout << "Withdrawal denied, insufficient funds" << endl;

cout << "Checking account balance for account # " << account1.getAccountNumber() <<
" is $" << account1.getAccountBalance() << endl << endl;
}
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SavingsAccount.h

C++
#pragma once
#include "BankAccount.h"

class SavingsAccount :
public BankAccount
{
public:
SavingsAccount(void);
~SavingsAccount(void);
double getAccountBalance(void);

void SetInterestRate(double);

private:

double interestRate;

int numberofDays;

double earnedInterest;

public:

double getInterestEarned(void);

int getNumberofDays(void);
};
Posted
Updated 18-Sep-16 17:24pm
v2

Try changing:
account2.setInterestRate(newInterestRate);

To
account2.SetInterestRate(newInterestRate);


And
account2.getNumberOfDays()

To
account2.getNumberofDays()


C++ and C is case sensitive.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Wendelius 20-May-12 17:35pm    
Good catch :)
Espen Harlinn 20-May-12 17:37pm    
Thanks Mika :-D
Wendelius 20-May-12 17:47pm    
OP's comment:
"thank you, The answer worked for me. I guess been looking at the codes too long and was missing the simple stuff."
thank you, The answer worked for me. I guess been looking at the codes too long and was missing the simple stuff.
 
Share this answer
 
Comments
Wendelius 20-May-12 17:47pm    
Instead of posting a new solution, use the "Have a Question or Comment?" button inside a solution to send a message.
#include<iostream.h>
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<string.h>

class account{

protected:
      char cname[20];
      int accno;
      char type;
      int bal;
public:
      account()
      {
        strcpy(cname," ");
        accno=0;
        type=' ';
        bal=0;
      }
      void input(){
        cout<<"Enter cname";cin>>cname;
        cout<<"Enter accno";cin>>accno;
        fflush(stdin);
        cout<<"Enter type"; cin>>type;
        fflush(stdin);
        cout<<"Enter bal";cin>>bal;
      }
      void display(){
            cout<<"\n Customer Name "<<cname;
            cout<<"\n Account Number "<<accno;
            cout<<"\n Type "<<type;
            cout<<"\n Balance "<<bal;
      }
      void deposit(){
            int amt;
            cout<<"\n Enter the amount to deposit";
            cin>>amt;
            bal=bal+amt;
      }
};
class savacct:public account{
      int inter;
      public:

      int comp_int(){
         int time1,rate1;
         rate1=10;
         cout<<"\n Enter time";cin>>time1;
         inter=bal*pow(1+rate1/100.0,time1)-bal;
         return inter;
      }

      void update_bal(){
         bal=bal+comp_int();
      }

      void withdrawal(){
         int amt;
         cout<<"\n Enter amount to withdrawn";
         cin>>amt;
         if(bal>=amt){
               bal=bal-amt;
         }
         else{
               cout<<"\n The amount cannot be withdrawn";
         }
      }
  };

class curacct:public account{
       int chq_bk;
       int penal;
       public:

       int min_bal(){
          int ret1=1;
          if(bal<=500){
             penal=50;
             bal=bal-penal;
             ret1=0;
          }
          else{
             cout<<"\n No penality imposed";
          }
          return ret1;
      }
      void withdrawal(){
          int amt;
          cout<<"\n Enter the amount to withdrawn";
          cin>>amt;
          int k=min_bal();
          if(k==1){
             if(bal>=amt)
             bal=bal-amt;
          }
          else{
              cout<<"\n The amount cannot be withdrawn";
          }
      }
   };

void main(){
      curacct c1;
      savacct s1;
      c1.input();
      c1.display();
      c1.deposit();
      c1.display();
      c1.withdrawal();
      c1.display();
      s1.input();
      s1.display();
      s1.deposit();
      s1.display();
      s1.withdrawal();
      s1.display();
}
 
Share this answer
 
v2
Comments
Patrice T 19-Sep-16 3:08am    
Do not use many questions.
Use Improve solution to update your solution.
Richard MacCutchan 19-Sep-16 3:28am    
Four year old question!
Patrice T 19-Sep-16 3:37am    
Yes I know, but he also used 2 solutions :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900