Please help, I think it should be simple but I am new to this and have been trying to figure out the problem but have not yet.
#include <iostream>
#include <iomanip>
#include <cctype> //needed to use toupper, accepts a single char as its arguement and rtns the uppercase equivalent
#include "Generic.h"
#include "Savings.h"
#include "CharRange.h" //CharRange class declaration
using namespace std;
//Function Prototypes
void displayMenu();
void deposit(Generic &);
void deposit(Savings &);
void withdraw(Generic &);
void withdraw(Savings &);
int main()
{
Generic check; //object of Generic class created
Savings save; //object of Savings class created
CharRange input ('A', 'G'); //object of CharRange class created, will check for chars A-G
char choice;
do
{
displayMenu();
choice = input.getChar(); //This returns only an uppercase A-G
switch(choice)
{
case 'A':
cout << endl;
cout << "The current balance is $";
cout << save.getBalance() << endl;
break;
case 'B':
cout << endl;
cout << "The current balance is $";
cout << check.getBalance() << endl;
break;
case 'C':
cout << endl;
cout << "There have been ";
cout << setw(1);
cout << save.getTransactions();
cout << " transactions.\n";
break;
case 'D':
cout << endl;
cout << "Interest earned for this period: $";
cout << fixed << showpoint << setprecision(2);
cout << save.getInterest() << endl;
break;
case 'E': deposit(save);
break;
case 'F': deposit(check);
break;
case 'G': withdraw(save);
break;
case 'H': withdraw(check);
case 'I':
save.calcInt();
cout << "Interest added.\n";
check.calcInt();
cout << "Interest added.\n";
}
} while(choice != 'G');
return 0;
}
//************ displayMenu ***************//
//***displays user's menu on the screen***//
void displayMenu()
{
cout << "\n Menu\n\n";
cout << "a) Display the Savings Account balance\n";
cout<< "b) Display the Checkings Account balance\n";
cout << "c) Display the number of transactions\n";
cout << "d) Display the interest earned for this month\n";
cout << "e) Make a Savings Account deposit\n";
cout << "f) Make a Checkings Account deposit\n";
cout << "g) Make a Savings Account withdrawal\n";
cout << "h) Make a Checkings Account withdrawal\n";
cout << "i) Add interest for this month\n";
cout << "j) Exit\n";
cout << "\nEnter your choice: ";
}
//***********deposit**********************//
void deposit(Generic &generic)
{
double dollars;
cout << "Enter the amount of the deposit: ";
cin >> dollars;
cin.ignore();
generic.deposit(dollars);
}
Prob is here i think:
void deposit(Savings &savings)
{
//double dollars;
//cout << "Enter the amount of the deposit: ";
//cin >> dollars;
//cin.ignore();
//savings.deposit(dollars);
}
//*********withdraw**********************//
// This function stores data input by the user //
// in the member of the Generic or Savings class //
// passed to the function by reference //
void withdraw(Generic &generic)
{
double dollars;
cout << "Enter the amount of the withdrawl: ";
cin >> dollars;
cin.ignore();
if(!generic.withdraw(dollars))
cout << "ERROR: Withdrawl too large.\n\n";
}
prob is here i think:
void withdraw(Savings &savings)
{
//double dollars;
//cout << "Enter the amount of the withdrawl: ";
//cin >> dollars;
//cin.ignore();
//if(!savings.withdraw(dollars))
//cout << "ERROR: Withdrawl too large.\n\n";
//}
cpp file for "Savings
#include <iostream>
#include "Savings.h"
using namespace std;
bool Savings::withdraw(double amount)
{
if (balance < amount)
return false; //not enough in the account
else
{
balance -= amount;
transactions++;
return true;
}
}
file for "Savings.h":
class Savings
{
private:
double balance;
double annualIntRate;
double monthlyIntRate;
double interest;
short int transactions;
char status;
public:
Savings(double annirate=0.18, double mirate=0, double bal = 0.0) //constructor
{ balance = bal; annualIntRate=annirate; monthlyIntRate = mirate;
interest = 0; transactions = 0;}
void deposit(double amount)
{balance += amount; transactions++;}
bool withdraw(double amount); //defined in withdraw.cpp
void calcInt()
{interest = balance * monthlyIntRate; monthlyIntRate=annualIntRate/12; balance += interest;
}
void monthlyProc(int withdrawls, double servCharge)
{
for (int count = 0; count > withdrawls; count++)
servCharge =+ 1;
}
void displayMenu();
double getBalance()
{return balance;
}
double getInterest()
{return interest;
}
double getTransactions()
{return transactions;
}
};