How can i get my program to run until it's told to exit? I want it to store the value that the user inputs and stay at that value until the user changes it again
Code:
//Bank program
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//Define Intergers
int Selection = 0;
float TransAmount = 0.0;
float Balance = 0.0;
cout << setw(15) << "ATM" << endl;
cout << "1: " << "Open Account" << endl;
cout << "2: " << "Deposit Funds" << endl;
cout << "3: " << "Withdraw Funds" << endl;
cout << "4: " << "Check Balance" << endl;
cout << "5: " << "Exit" << endl;
cout << "Make your selection: " << endl;
cin >> Selection;
cout << endl;
if (Selection == 1) {
cout << "Enter the amount to open your account with: ";
cin >> TransAmount;
cout << "Your new balance is: " << Balance + TransAmount << endl;
cout << endl;
}//End if
if (Selection == 2) {
cout << "Enter the amount you would like to deposit: ";
cin >> TransAmount;
cout << "Your new balance is: " << Balance + TransAmount << endl;
cout << endl;
}//End if
if (Selection == 3) {
cout << "Enter amount you would like to withdraw: ";
cin >> TransAmount;
if (TransAmount > Balance)
cout << "Insufficient Funds" << endl;
else
cout << "Your new balance is: " << Balance - TransAmount << endl;
}//End else
if (Selection == 4) {
cout << " Your balance is: " <<Balance << endl;
}//End if
}//End main function