I'm working on an assignment for class, in which:
1) I need to display a menu for fruit selection.
2) After selection is made, program asks for quantity (double).
3) Program should enter selection in class array (this seems fine).

Where I'm having the problem is in the do while loop that produces the menu. The condition is that should break the loop is when the user enters a selection of 11.

Currently, when "11" selected, the program locks up. The program should move to a cout statement, and run a function calculating total. I know it's a simple logic problem, and I'm just not seeing it.

Any help would be much appreciated. Thanks!

        showMenu(nameArray, priceArray);

	cout << "Please enter a selection: \n";
	cin >> choice;
        while (choice > 11 || choice <= 0)
			cout << "Invalid selction, please re-enter:\n";
			cin >> choice;

	cout << "How many pounds of " << nameArray[choice-1] << " would you like?\n";
		cin >> pounds;
	shoppingList[count].setItem(nameArray[choice - 1], priceArray[choice-1], pounds);

} while (choice != 11);

Since you process choice even when it's 11, my guess is nameArray[11-1] is beyond the array bounds.

That's part of the problem, I'm not sure where or how, but I need to break out of the loop when the user enters 11. It should move to the lines below the do/while loop.

Is there a piece of code I need to move to get this to process properly?


Sorry....didn't think about your response enough.

Thank you, WaltP. I got it to work.