This code that I wrote in C++ is a simple menu driven program that demonstrates how to construct a menu using C++. What is good about this program is that it does not accept invalid entries there's no way our menu program will crash for invalid entries from our user. I hope this program can help other people how to make their own menu program using C++ as there programming language.
If you have some questions about please send me an email at jakerpomperada@yahoo.com and jakerpomeperada@gmail.com
Thank you very much.
Sample Output of Our Program
Program Listing
// Created By: Mr. Jake Rodriguez Pomperada, MAED-IT
// Date : April 3, 2010 Saturday
// Tool : C++
// Email : jakerpomperada@yahoo.com
// Facebook Address : jakerpomperada@yahoo.com
#include <iostream>
using namespace std;
void menu()
{
char choice;
system("cls");
cout << "\n\t\t MENU DEMO Version 1.0 ";
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 << "\n\n You select Add";
cout << "\n\n";
system("pause");
menu();
}
else if (choice == '2') {
cout << "\n\n You select Edit";
cout << "\n\n";
system("pause");
menu();
}
else if (choice == '3') {
cout << "\n\n You select Delete";
cout << "\n\n";
system("pause");
menu();
}
else if (choice == '4') {
cout << "\n\n You select View";
cout << "\n\n";
system("pause");
menu();
}
else if (choice == '5') {
cout << "\n\n\tThanks for using this program and return to OS.";
system("pause");
menu();
}
else if (choice != '5') {
cout << "\n\n\n \t\t\t Invalid Option Try Again...";
cout << "\n\n";
system("pause");
}
}
main()
{
char choice;
do {
menu();
} while (choice != '5');
}
No comments:
Post a Comment