I have a do while loop that has if statements in it. The problem is that once it is done executing one part of the if statement, it automatically moves to the next part of the if statement. What I need it to do is start over at the beginning of the do while loop. Please help!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void menu()
{
expense all_expenses[100];
int num_expenses=0;
char choice;
do
{
cout<<"Enter 'a' to enter new expenses, 'd' to display expenses,"<<endl;
cout<<" enter 'f' to find an expense or 'q' to quit"<<endl;
cin>>choice;
cin.ignore(100,'\n');
if ('a'==choice)
add(all_expenses, num_expenses);
elseif ('d'==choice)
display(all_expenses, num_expenses);
else ('f'==choice);
find(all_expenses,num_expenses);
}while(choice!='q');
}
Say the user enters an 'a' for the add function, once that function completes it moves to the display function. I need the program to allow the user to choose what to do next. i.e I need the loop to start again on line 8.