This should be a simple question.. I'll do my best to explain it.
Ok let say I have code that looks like this..
int loop2;
do{
cout<<"Here are your options:"<<endl;
cout<<"1: Deposit \t"<<" 2: WithDraw"<<endl;
cout<<"3: Balance \t"<<" 4: Loan"<<endl;
cout<<"5: Help \t"<<" 6: Exit"<<endl;
cout<<"Please choise a number 1-5 or 6 to exit"<<endl;
cout<<": ";
cin>>loop2;
//Lets start the MASTER IF STATEMENTS
if(loop2==1){
Deposit(line);
}
else if(loop2==2){
Withdraw(line);
}
else if(loop2==3){
//balance
ifstream fin(line);
if(!fin)
{
cout<<"Could not open account file!";
cout<<endl;
cout<<"Press any button to continue...";
cin.ignore(2);
}
getline(fin, balance);
cout<<"Your balane: "<<balance<<endl;
fin.close();
}
else if(loop2==4){
Loan();
}
else if(loop2==5){
Help();
}
else if (loop2==6)
{
cout<<"Hit any key to continue...";
}
else if(!loop2==1||2||3||4||5||6){
cout<<"ERROR, Invaid entry! Press any button to Try again!!";
cin.ignore(2);
}
}while(loop2!=6);
For the most part if you type any number outside of the range 6. You will get the error massage.. However, if you type in a charter of any kind you get an infinite loop...
What I want to know is how can I produce a question lock, that will only take in the input of the statements, that it supports?
One last bonus question. How can I set up a question line that can read the enter button.. Lets say the user doesn't type anything but presses enter anyway. I would like to make a program that can detect these kinds of problems, and display the proper error message..
Any solution code or web links would do a world of good for me, and my code.

New Topic/Question
Reply



MultiQuote





|