need help! need to prevent withdraw function from occuring when savings balance is below 25. The program will run, although when the balance gets below $25 it just states "account inactive" which is fine but then the menu does not display again. This is what i have so far:
int main()
{
Generic check; //object of Generic class created
Savings save; //object of Savings class created
CharRange input ('A', 'J');
//object of CharRange class created, will check for chars A-J
char choice;
save.status(true);
void withdraw(Savings &savings)
{
int balance;
double dollars;
savings.status(false);
cin >> dollars;
cin.ignore();
if(!savings.withdraw(dollars))
cout << "ERROR: Non-sufficient funds.\n\n";
}
in "Savings.cpp" I have:
#include <iostream>
#include "Savings.h"
using namespace std;
bool Savings::withdraw(double amount)
{
if (balance < amount)
return false;
else if (balance < 25)
return false; //not enough in the account
else
{
balance -= amount;
withdrawals++;
transactions++;
return true;
}
}
void Savings::status(bool active)
{
if (balance > 25)
{
bool active = true;
cout << "Account is active\n";
cout << "Enter the amount of the withdrawl: ";
}
else
{
bool active = false;
cout << "Account is inactive\n";
}
}