0

Well this is my assignment for uni. I've done all the main and difficult bits- and now I cannot believe that I'm stuck at the simplest task. Im told to make a menu that gives user three options to choose from. Choosing option 1 will ask to choose from 3 more options. What i want to do is when user choose option 1 of 1...then call the function twostacks(). But instead of asking for input...the console just prints out "Is palindrome". The function does its job if I just simply call it at the first line in my main function. Heres the main function code:

```
void twostacks()
{
string s;
StackType<char> stack1(40);
StackType<char> stack2(40);
char c1;
int count=0;
cout<<"enter string: press return."<<endl;
getline(cin,s);
while(!s.empty())
{
if(isalpha(s.at(0)))
{
stack1.Push(tolower(s.at(0)));
s.erase(0,1);
count++;
}
else if(!isalpha(s.at(0)))
{
s.erase(0,1);
}
}
int a=count/2;
for(int i=0; i<a; i++)
{
c1=stack1.Top();
stack2.Push(c1);
stack1.Pop();
}
if((count%2)==0)
{
while(!stack1.IsEmpty() && !stack2.IsEmpty())
{
if(stack1.Top()==stack2.Top())
{
stack1.Pop();
stack2.Pop();
}
else break;
}
}
else if((count%2)!=0)
{
stack1.Pop();
while(!stack1.IsEmpty() && !stack2.IsEmpty())
{
if(stack1.Top()==stack2.Top())
{
stack1.Pop();
stack2.Pop();
}
else break;
}
}
if(stack1.IsEmpty() && stack2.IsEmpty())
cout<<"Is Palindrome"<<endl;
else
cout<<"Not Palindrome"<<endl;
}
int main()
{
cout<<"Choose your operation:\n"<<"[1]Palindrome\n"<<"[2]Match Parenthesis\n"<<"[3]Evaluate postfix expressions\n";
cout<<endl<<endl;
int c,p;
cin>>c;
if(c==1)
{
cout<<"Choose one of the following strategies:\n";
cout<<"(1)Using two stacks\n";
cout<<"(2)Using one stack and one queue\n";
cout<<"(3)Using one stack\n";
cin>>p;
if(p==1)
{
twostacks();
}
}
return 0;
}
```