This is a small portion of the code i am working on. I am try to figure how i can exit this loop when asked to do so. But i have to allow the user to make multiple changes until the user tells the program to exit. i have every thing else figured out in the program but one part.
int main()
{
int acct;
char DorW, acctt;
double minbalance, cbalance, balance, total;
ifstream indata;
ofstream outdata;
indata.open("bank.dat");
indata >> acct;
while(!indata.eof())
{
indata >> acctt >> minbalance >> cbalance;
cout << fixed << setprecision(2) << showpoint;
if (acctt == 's' || acctt == 'S')
{ cout << "Would you like to deposit or withdrawal funds: " << endl;
cout << "D or d (Deposit), W or w (withdrawal), E or e (exit) :" << endl;
cin >> DorW;
cout << endl;
do
{
switch (DorW)
{
case'd':
case'D':
cout << "How much to deposit: $" << endl;
cin >> total;
cbalance = cbalance + total;
break;
case'w':
case'W':
cout << "How much to withdrawl: $" << endl;
cin >> total;
cbalance = cbalance - total;
if (cbalance >= 0)
{cout << "Sucessfully withdrawn" << endl;}
else
{ cout << "Insufficient funds - the withdrawal is being denied." << endl;
cbalance = cbalance + total;}
break;
case'e':
case'E':
DorW = 'e';
break;
default:
cout << "Invalid selection type." << endl;
break;
}
if(DorW != 'e' || DorW != 'E') break;
cout << "Would you like to deposit or withdrawal funds: " << endl;
cout << "D or d (Deposit), W or w (withdrawal), E or e (exit) :" << endl;
cin >> DorW;
cout << endl;
}while(true);
}
else
{cout << "Would you like to deposit or withdrawal funds: " << endl;
cout << "D or d (Deposit), W or w (withdrawal), E or e (exit) :" << endl;
cin >> DorW;
cout << endl;
do {
switch (DorW)
{
case'd':
case'D':
cout << "How much to deposit: $" <<endl;
cin >> total;
cbalance = cbalance + total;
break;
case'w':
case'W':
cout << "How much to withdrawl: $" << endl;
cin >> total;
cbalance = cbalance - total;
if (cbalance >= 0)
{cout << "Sucessfully withdrawn" << endl;}
else
{ cout << "Insufficient funds - the withdrawal is being denied." << endl;
cbalance = cbalance + total;}
break;
case'e':
case'E':
break;
default:
cout << "Invalid selection type." << endl;
} cout << "Would you like to deposit or withdrawal funds: " << endl;
cout << "D or d (Deposit), W or w (withdrawal), E or e (exit) :" << endl;
cin >> DorW;
cout << endl;
}while (DorW != 'e' || DorW != 'E');
}
outdata << acct << " " << acctt << " " << minbalance << " " << balance << endl;
indata>>acct;
}
return 0;
}
i have a .dat file that i am getting the information from. their are some calculations left out that i will be incorporating. I have compiled the program and it shows no errors, but for some reason it just keeps asking the quest no matter how many times i enter 'e' for exit. What i need to do is exit the do loop the and continue one with the program. I know the outdata portion is not right i will deal with after i get this problem resolved.