How to create a menu

Help me i need to create a Menu Like this

Menu

[1] Seasons of the year

[2] BINGO

[3] My Loop

[4] Exit
The program can only exit when the user chooses 4

Then When i Input 1 it will run the program that i created for the SEASON OF THE YEAR same with 2 and 3 :)
This is the same subject as your previous posts, just keep the other Topic going. If you post something, it will be at the top of the list. The problem is that someone might reply, only to find that someone else has said exactly the same thing in the other topic. So this is ultimately a time waster.
The if/else if statement allows your program to branch into one of several possible paths. It performs a series of tests (usually relational) and branches when one of these tests is true. The switch statement is a similar mechanism. It, however, tests the value of an integer expression and then uses that value to determine which set of statements to branch to. Here is the format of the switch statement:

Example of switch:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// The switch statement in this program tells the user something
// he or she already knows: what they just entered!
#include <iostream>
using namespace std;

int main()
{
   char choice;

   cout << "Enter A, B, or C: ";
   cin >> choice;
   switch (choice)
   {
      case 'A': cout << "You entered A.\n";
                break;
      case 'B': cout << "You entered B.\n";
                break;
      case 'C': cout << "You entered C.\n";
                break;
      default:  cout << "You did not enter A, B, or C!\n";
   }
   return 0;
}
closed account (E0p9LyTq)
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
49
50
51
// a simple menu

#include <iostream>

int main()
{
   unsigned short response = 0;
   bool menuQuit = false;

   while (menuQuit == false)
   {
      do
      {
         std::cout << "What action would you like to take?\n"
                   << " 1) Seasons of the Year\n"
                   << " 2) BINGO\n"
                   << " 3) (My Loop)\n"
                   << " 4) Exit\n"
                   << ": ";
         std::cin >> response;
         std::cout << "\n";
      }
      while (response > 4);

      switch (response)
      {
      case 1:
         std::cout << "Seasons of the Year was selected!\n\n";
         break;

      case 2:
         std::cout << "BINGO was selected!\n\n";
         break;

      case 3:
         std::cout << "(My Loop) was selected!\n\n";
         break;

      case 4:
         std::cout << "Exiting....\n";
         menuQuit = true;
         break;

      default:
         std::cout << "\n** Invalid Menu Selection!! **\n\n";
         break;
      }
   }

   return 0;
}
Topic archived. No new replies allowed.