Every time you go round, you are calling a whole new function. The function starts and does this:
1 2 3
double withdraw,balance,deposit;
int iAnswer,option;
balance=10000;
So of course balance always seems to be 10000. You are creating a whole new balance every time, over and over.
You've basically completely misunderstood how a loop works, and how functions work. Do NOT call MainMenu() over and over again.
You should have a loop inside MainMenu(). It should look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void MainMenu(){
double balance = 10000;
int iAnswer = 1;
while(iAnswer==1)
{
// all your code
// lots of code
// End of MainMenu() function
cout<<"Do you still want to proceed to another transaction?"<<endl;
cout<<"1. Yes"<<endl;
cout<<"2. No"<<endl;
cin>>iAnswer;
}
void MainMenu()
{
bool isVeryFirstTime = true;
double balance = 10000;
int iAnswer = 1;
while(iAnswer==1)
{
// all your code
// lots of code
// End of MainMenu() function
if (isVeryFirstTime)
{
isVeryFirstTime = false;
}
else
{
cout<<"Do you still want to proceed to another transaction?"<<endl;
cout<<"1. Yes"<<endl;
cout<<"2. No"<<endl;
cin>>iAnswer;
}
}