Menu to Choose Game

Hey guys! I'm new here and in need of help. I need to figure out how to write a program that will bring up a game menu. It will first prompt the user for his/her name, then bring him/her to the menu. After the menu is displayed, the user will be given the option to choose between two games. (Option A and Option B). I need to know how to utilize an if or switch statement in order to bring the user to a separate game within the same program. The programs for the Madlib and Choose Your Own Adventure games are already written as separate programs. My goal is to write a program where you have the option to choose between these two games. Thank You!

-Brendan
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
//Game Menu
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string myName;
    cout << "What is your name?" << endl;
    cin >> myName;
    
    cout << "***************************************************" << endl;
    cout << " " << endl;
    cout << "                 Welcome, " << myName << "!" << endl;
    cout << " " << ::endl;
    cout << "Please choose a letter from the following options:" << endl;
    cout << " " << endl;
    cout << "A) Choose your own adventure!" << endl;
    cout << "B) Madlib!" << endl;
    cout << " " << endl;
    cout << "***************************************************" << endl;
    
    
    
    

return 0;
    }
Last edited on
I think that's a good start...

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
#include <iostream>
#include <string>
#include <cctype> 

using namespace std;

int main()
{
	string myName;
	char option;

	cout << "What is your name?" << endl;
	cin >> myName;

	cout << "***************************************************" << endl;
	cout << " " << endl;
    cout << "                 Welcome, " << myName << "!" << endl;
  	cout << " " << ::endl;
    cout << "Please choose a letter from the following options:" << endl;
    cout << " " << endl;
    cout << "A) Choose your own adventure!" << endl;
    cout << "B) Madlib!" << endl;
    cout << " " << endl;
    cout << "***************************************************" << endl;
    cout << "Your option : ";
    cin >> option;
    option = toupper(option);

    switch (option)
    {
    	case 'A':
    	// Write your statements here...
    	break;
    	case 'B':
    	// Write your statements here...
    	break;
    	default:
    	cout << "Invalid option.";
    	break;
    }

    return 0;
}
Last edited on
Thank you! Really helped a lot.
Topic archived. No new replies allowed.