How to create a complete Main menu for your management system using C++ (Part 2)


Following code will be very helpful if you are creating some kind of management system. Study this code carefully. you'll understand this code very easily. Here there are some "cout" codes and if statement to and some "cin" for user inputs.  without further due here is the code,


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
void main_menu() {
    system("cls");
    int choice;

    cout << "|---- Atlas Gymnasium (PVT)LTD ----|" << endl << endl << endl;
    cout << "Main Menu" << endl << endl << endl;
    cout << "1. Register member" << endl;
    cout << "2. View all members" << endl;
    cout << "3. Find member" << endl;
    cout << "4. Edit member" << endl;
    cout << "5. Remove member" << endl;
    cout << "6. Exit" << endl <<endl <<endl;

    cout << "Please enter the related NUMBER for your choice: ";
    cin >> choice;

    if (choice == 1){
        system("cls");
        cout << "You are in the register member mode" << endl;
    }
    else if (choice == 2){
        system("cls");
        cout << "You are in the view all members mode" << endl;
    }
    else if (choice == 3){
        system("cls");
        cout << "You are in the Find member mode" << endl;
    }
    else if (choice == 4){
        system("cls");
        cout << "You are in the edit member mode" << endl;
    }
    else if (choice == 5){
        system("cls");
        cout << "You are in the remove member mode" << endl;
    }
    else if (choice == 6){
        system("cls");
        cout << "You are about to exit...." << endl;
        system("pause");
    }
    else {
        system("cls");
        cout << "The number you entered is not valid. please check again." << endl;
        system("pause");
        main_menu();
    }
}
 
 If you have any questions ask them by commenting in the comment section. and please be kind enough to share with this your friends.

Comments