I have the majority of my program written, however, I cannot get my menu in the
ID: 3552806 • Letter: I
Question
I have the majority of my program written, however, I cannot get my menu in the main.cpp to call my functions and get user input. The first part is correct it is just the menu that needs adjustment and whatever else to make the menu function. Here is the assignment for the program.
Create a new project that consists of the base class BankAccount.
The BankAccount class should contain, at minimum, the following members.
The class CheckingAccount should contain, at a minimum, the following members.
The class CheckingAccount should contain, at a minimum, the following members.
#pragma once
class CBankAccount
{
public:
CBankAccount();
~CBankAccount();
int getAccountNumber(void);
void setAccountNumber(int num);
void setAccountBalance(double balance);
double getAccountbalance(void);
void depositMoney (double depositAmount);
bool withdrawMoney (double withdrawAmount);
protected:
int accountNumber;
double accountBalance;
};
#include <iostream>
#include "BankAccount.h"
#include "CheckingAccount.h"
#include "SavingsAccount.h"
using namespace std;
CBankAccount::CBankAccount()
{
}
CBankAccount::~CBankAccount(void)
{
}
int CBankAccount::getAccountNumber(void)
{
return accountNumber;
}
void CBankAccount::setAccountBalance(double balance)
{
accountBalance = balance;
}
double CBankAccount::getAccountbalance(void)
{
return accountBalance;
}
void CBankAccount::depositMoney(double depositAmount)
{
cout << "Enter deposit amount: $";
cin >> depositAmount;
accountBalance += depositAmount;
}
bool CBankAccount::withdrawMoney(double withdrawAmount)
{
if(accountBalance - withdrawAmount < 0)
return false;
else
{
accountBalance -= withdrawAmount;
return true;
}
cout << "Enter amount you wish to withdraw: $";
cin >> withdrawAmount;
accountBalance -= withdrawAmount;
}
void CBankAccount::setAccountNumber(int num)
{
accountNumber = num;
}
#pragma once
#include "bankaccount.h"
class CCheckingAccount:public CBankAccount
{
public:
CCheckingAccount(int);
~CCheckingAccount(void);
bool withdrawMoney(double);
double getAccountBalance(void);
void depositMoney(double depositAmount);
private:
int transactionCount;
};
#include <iostream>
#include "CheckingAccount.h"
#include "BankAccount.h"
#include "SavingsAccount.h"
using namespace std;
CCheckingAccount::CCheckingAccount(int)
{
}
CCheckingAccount::~CCheckingAccount(void)
{
}
double CCheckingAccount::getAccountBalance(void)
{
return accountBalance;
}
bool CCheckingAccount::withdrawMoney(double withdrawAmount)
{
transactionCount ++;
if(transactionCount > 3)
{
if(accountBalance - withdrawAmount - 0.5 < 0)
return false;
else
{
accountBalance -= (withdrawAmount + 0.5);
cout << "Fifty cent transaction fee included." << endl;
return true;
}
}
else
{
if(accountBalance -withdrawAmount < 0)
return false;
else
accountBalance -= withdrawAmount;
return true;
}
cout << "Enter amount you wish to withdraw: $";
cin >> withdrawAmount;
accountBalance -= withdrawAmount;
}
void CCheckingAccount::depositMoney(double depositAmount)
{
cout << "Enter deposit amount: $";
cin >> depositAmount;
accountBalance += depositAmount;
}
#pragma once
#include "bankaccount.h"
class CSavingsAccount:public CBankAccount
{
public:
CSavingsAccount(int);
~CSavingsAccount(void);
double getAccountBalance(void);
void setInterestRate(double);
double getInterestEarned(void);
int getNumberOfDays(void);
private:
double interestRate;
int numberOfDays;
double earnedInterest;
};
#include <iostream>
#include "SavingsAccount.h"
#include "BankAccount.h"
#include "CheckingAccount.h"
using namespace std;
CSavingsAccount::CSavingsAccount(int)
{
}
CSavingsAccount::~CSavingsAccount(void)
{
}
double CSavingsAccount::getAccountBalance(void)
{
accountBalance += earnedInterest;
return accountBalance;
}
void CSavingsAccount::setInterestRate(double newInterestRate)
{
interestRate = newInterestRate/365;
}
double CSavingsAccount::getInterestEarned(void)
{
earnedInterest = accountBalance * (numberOfDays * interestRate);
return earnedInterest;
}
int CSavingsAccount::getNumberOfDays(void)
{
numberOfDays = rand()%8;
return numberOfDays;
}
#include "BankAccount.h"
#include "CheckingAccount.h"
#include "SavingsAccount.h"
#include <iostream>
#include <iomanip>
#include <Windows.h>
#include <conio.h>
using namespace std;
void main (void)
{
srand(GetTickCount());
CCheckingAccount account1(24680);
CSavingsAccount account2(13579);
account1.setAccountNumber(24680);
account2.setAccountNumber(13579);
account1.setAccountBalance(100);
account2.setAccountBalance(100);
account2.setInterestRate(0.03);
//Checking Account
cout << "Account Number: "<< account1.getAccountNumber() << endl;
cout << "Account Type: Checking" << endl;
cout << "Balance: $"<< account1.getAccountBalance() << endl;
//Savings Account
cout << " Account Number: " << account2.getAccountNumber() << endl;
cout << "Account Type: Savings" << endl;
cout << "Balance: $"<< account2.getAccountbalance() << endl;
cout << "Number of days since last transaction:" << account2.getNumberOfDays() << endl;
cout << "Interest earned since last transaction: $" << account2.getInterestEarned() << endl;
char type;
cout << " Enter S for savings account or C for checking account: ";
cin >> type;
int choice;
if(type == 'c' || type == 'C')
{
account1.getAccountBalance();
while(int i = 0)
{
i > 0 || i < 5;
}
cout << " Please select a menu option below: ";
cout << "1) Make a deposit ";
cout << "2) Make a withdraw ";
cout << "3) Return account balance ";
cout << "4) Exit ";
cin >> choice;
switch (choice)
{
case 1:&CBankAccount::depositMoney;
_getch();
break;
case 2:&CCheckingAccount::withdrawMoney;
_getch();
break;
case 3:&CCheckingAccount::getAccountBalance;
_getch();
break;
case 4:
_getch();
break;
default: " Invalid entry, please try again.";
}
}
else
{
if(type == 's' || type == 'S')
{
account2.getAccountBalance();
while(int i = 0)
{
i > 0 || i < 5;
}
{
cout << " Please select a menu option below: ";
cout << "1) Make a deposit ";
cout << "2) Make a withdraw ";
cout << "3) Return account balance ";
cout << "4) Exit ";
cin >> choice;
switch (choice)
{
case 1:&CSavingsAccount::depositMoney;
_getch();
break;
case 2:&CSavingsAccount::withdrawMoney;
_getch();
break;
case 3:&CSavingsAccount::getAccountBalance;
_getch();
break;
case 4:
_getch();
break;
default: " Invalid entry, please try again.";
}
}
}
}
cin.ignore(2);
return;
}
PLEASE USE MY CODE, I DO NOT WANT A NEW CODE!!!! THANKS.
Explanation / Answer
give me some time....i will solve this