Wednesday, January 28, 2015

Menu in C++

In this article I would like to share with you one of my c++ codes that I wrote a long time ago that will give you an idea how to construct a navigational menu using C++ as our programming language. This sample menu that I wrote uses switch case statement for the selection of entries in our menu. 

I hope you will find my work useful in your learning in C++ programming. If you have some questions regarding on my work feel free to send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much and Happy Programming.




Sample Output of Our Program


Program Listing

// Created By: Mr. Jake Rodriguez Pomperada, MAED-IT
// Date : April 1, 2010 Thursday
// Tool : C++
// Email : jakerpomperada@yahoo.com
// Facebook Address : jakerpomperada@yahoo.com

#include <iostream>
#include <stdlib.h>

using namespace std;

main() {

    char choice;

    do {
       system("cls");
        cout << "\n\t\t     MENU IN C++ ";
        cout << "\n\n\t Created By: Mr. Jake R. Pomperada, MAED-IT";
        cout << "\n\n";
        cout << "\n\t\t\t 1. Add Record ";
        cout << "\n\t\t\t 2. Edit Record ";
        cout << "\n\t\t\t 3. Delete Record ";
        cout << "\n\t\t\t 4. View Record ";
        cout << "\n\t\t\t 5. Quit Program ";
        cout << "\n\n";
        cout << "\n\t\t Enter Your Choice :=> ";
        cin >> choice;

        if (choice == '1') {
            cout << "You select Add";
            break;
        }
        else if (choice == '2') {
            cout << "You select Edit";
            break;
        }
    else if (choice == '3') {
            cout << "You select Delete";
            break;
        }
        else if (choice == '4') {
            cout << "You select View";
            break;
        }
         else if (choice == '5') {
            cout << "\n\n\tThanks for using this program and return to OS.";
            break;
        }
     else if (choice != '5') {
         cout << "\n\n\n \t\t\t Invalid Option Try Again...";
         cout << "\n\n";
        system("pause");
          }

    } while (choice != '5');
    cout << "\n\n";
    system("pause");
}


No comments:

Post a Comment