This programs purpose is to be a menu driven check and balancing program. I am trying to get the variable "balance" to remember the value it holds after specific operations have been done to it. I'm fairly new to C++ and I can't find this information anywhere.
int main(void)
{
double balance, deposit, withdraw;
char select;
std::cout << "Welcome to the check balancing program." << std::endl;
std::cout << "Please enter the current balance : " << std::endl;
std::cin >> balance;
std::cout << "Current balance : " << balance << std::endl;
do
{
std::cout << "please make your selection. \n";
std::cout << "W/w : Withdraw, " << "D/d : Deposit, " << "E/e : Ex <<std::endl;
std::cin >> select;
switch (select)
{
case 'W' : case 'w':
std::cout << "Please enter a withdrawal amount : ";
std::cin >> withdraw;
std::cout << "withdraw : " << withdraw << std::endl;
std::cout << "Remaining balance : " << (balance = balance - withdraw) << std::endl;
break;
case 'D' : case 'd':
std::cout << "Please enter a deposit amount : ";
std::cin >> deposit;
std::cout << "deposit : " << deposit << std::endl;
std::cout << "Remaining balance : " << (balance = balance + deposit) << std::endl;
break;
case 'E' : case 'e':
std::cout << "The new balance : " << balance << std::endl;
std::cout << "Thank you for using check balance program. Goodbye." << std::endl;
break;
default:
std::cout << "You have entered an invalid code. Please try again." << std::endl;
}
} while (select != 'e');
}