#endif
class BankAccount
{
public:
double enterAccountData();
double computeInterest();
void displayAccount();
private:
int accountNumber;
double accountBalance;
static const double RATE;
}
#include "stdafx.h"
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <dos.h>
#include <ctype.h>
#include<iostream>// holds the cin and cout commands
#include<conio.h>// holds the getche() instruction
using namespace std;
//#include "BankAccount.h"
double RATE = .03;
double BankAccount::enterAccountData()
{
double number;
double balance;
cout<<"Enter the account number"<<endl;
cin>>number;
while(number<0){
cout<<"Account number can not be negative."<<endl<<"Enter account number."<<endl;
cin>>number;
}
while(number<1000){
cout<<"Account number can not be less than 1000."<<endl<<"Enter account number."<<endl;
cin>>number;
cout<<endl;
}
cout<<"Enter the account balance"<<endl;
cin>>balance;
while(balance<0){
cout<<"Account balance can not be negative."<<endl<<"Enter account balance."<<endl;
cin>>balance;
cout<<endl;
}
}
double BankAccount::computeInterest()
{
double years;
double balanceYear, balance1;
cout<<number<<endl;
balance1=balance;
int i=1;
while(i<=years){
balanceYear=balance1+(balance1*RATE);
cout<<"Year "<<i<<": the balance is "<<balanceYear<<endl;
balance1=balanceYear;
i++;
}
}
void BankAccount::displayAccount()
{
cout<<"The bank account number is "<<number<<"."<<endl;
cout<<"The bank account balance is "<<balance<<"."<<endl;
}
int main ()
{
BankAccount A;
A.enterAccountData();
A.computeInterest();
A.displayAccount();
return 0;
}
// getche(); // necessary to hold the output for the user to read
//}
It wont compile. i dont think the implementation is correct, any suggestions?