Почему выход из подменю прерывает работу всей программы?

Проблема: При выходе из подменю, прерывается цикл работы всей программы. Я попыталась создать вторую булевую переменную, значение которой true, при выборе case exit значение переменной меняется на false. Код:

    #include <iostream>
#include <Windows.h>
using namespace std;

int main() {
    system("Color 70");
    cout << "\n\tHello!" << endl;
    double  current_price = 0, pencil_price = 1.2, total_price = 0;
    int book_price = 20, notebook_price = 7, paints_price = 6, book_Q = 10, notebook_Q = 4, pencil_Q = 13, num = 0, paints_Q = 6;
    enum opt { NEW_PURCHASE = 1, TOTAL_REVENUE = 2, EXIT = 0 };
    enum purch_opt { BOOK = 1, PENCIL = 2, NOTEBOOK = 3, PAINTS = 4,GETTOTAL=5, exit = 0 };
    int choiceOPT = 0, choicePurchase = 0, userBookQ = 0, userNotebookQ = 0, userPencilQ = 0, userPaintskQ = 0, orderNumber = 1;
    bool mainIsOn = true,secondIsOn = true;

    while (mainIsOn) {
        cout << "===============================\n";
        cout << "\tOPTIONS\n";
        cout << "===============================\n";
        cout << "\t1 - NEW PURCHASE\n";
        cout << "\t2 - TOTAL REVENUE\n";
        cout << "\t0 - EXIT\n";
        cin >> choiceOPT;
        switch (choiceOPT) {
        case TOTAL_REVENUE://2
            total_price += current_price;
            if (total_price == 0) cout <<"Tab is empty\n";
            else cout << "Total price is " << total_price << "$";
            break; 
            while (secondIsOn) {
           
        case NEW_PURCHASE://1
            for (int num = 1; num < 3; num++) {
                cout << '.';
                Sleep(600);
            }
            system("cls");
            cout << "Chosen option : PURCHASE \n";
            system("Color 71");
            cout << "\t1 - BOOK (20$) (10)\n";
            cout << "\t2 - PENCIL (1.2$) (13)\n";
            cout << "\t3 - NOTEBOOK (7$) (4)\n";
            cout << "\t4 - PAINTS (6$) (6)\n";
            cout << "\t-------------------\n";
            cout << "\t5 - GET TOTAL\n";
            cout << "\t0 - BACK TO MAIN MENU\n";
            cout << "\t=======================\n";
            cout << "Enter option:\n";
            cin >> choicePurchase;//user purchase input
            switch (choicePurchase) {

            case BOOK://1.1
                cout << "ORDER N" << orderNumber << endl;
                cout << "Enter quantity:\n";
                cin >> userBookQ;
                if (userBookQ <= book_Q && userBookQ > 0) {
                    current_price += book_price * userBookQ;
                    cout << "current price " << current_price << "$" << endl;
                }
                else cout << "Wrong amount!" << endl;
                break;
            case PENCIL://11.2
                cout << "ORDER N" << orderNumber << endl;
                cout << "Enter quantity:\n";
                cin >> userPencilQ;
                if (userPencilQ <= pencil_Q && userPencilQ > 0) {
                    current_price += pencil_price * userPencilQ;
                    cout << "current price " << current_price << "$" << endl;
                }
                else cout << "Wrong amount!" << endl;
                break;

            case NOTEBOOK://1.3
                cout << "ORDER N" << orderNumber << endl;
                cout << "Enter quantity:\n";
                cin >> userNotebookQ;
                if (userNotebookQ <= notebook_Q && userNotebookQ > 0) {
                    current_price += notebook_price * userNotebookQ;
                    cout << "current price " << current_price << "$" << endl;
                }
                else cout << "Wrong amount!" << endl;
                break;

            
            case PAINTS://1.4
                cout << "ORDER N" << orderNumber << endl;
                cout << "Enter quantity:\n";
                cin >> userPaintskQ;
                if (userPaintskQ <= paints_Q && userPaintskQ > 0) {
                    current_price += paints_price * userPaintskQ;
                    cout << "current price " << current_price << "$" << endl;
                }
                else cout << "Wrong amount!" << endl;
                break;
            case GETTOTAL:
                total_price += current_price;
                if (total_price == 0) cout << "your tab is empty\n\t";
                else cout << "Total price is " << total_price << "$";
                orderNumber += 1;
                break;
            case exit://! НЕ ВОЗВРАЩАЕТ В ГЛАВНОЕ МЕНЮ
                secondIsOn = false;
                break;

            }


            }
        case EXIT:
            mainIsOn = false;
            break;



        }
    }
    return 0;
}

Ответы (1 шт):

Автор решения: Harry

Потому что break прекращает только наиболее вложенный case. Вы вываливаетесь прямо в

case EXIT:
    mainIsOn = false;
    break;

Вам поможет

break;
case EXIT:

Вот результат:

введите сюда описание изображения

→ Ссылка