Help with a simple menu system

I am new to programming and need help at probably the easiest bit of my project.
my assignment is to create a blackjack game, however it is with menu system i am already struggling.

Here is the code i have so far:

#include <iostream>
using namespace std;


int main ()

{
cout << "\n \3 \4 BLACKJACK \5 \6 \n";
cout << " _________________ \n\n";
cout << " [1] - Play\n";
cout << " [2] - Rules\n";
cout << " [3] - Quit\n";

}

i need help with picking the options from the main menu.
any help will be greatly appreciated
EDIT: i have attempted a switch but am very new and as expected it did not work
Last edited on
Well, look at the chapter that covers input in your book.
...book?
Last edited on
@Rory Ayres

Here is a small Factorial program, that uses the switch statement. Entering 1 or 2, sends you to the rules routine, 3 to 7, prints out the inputted variable and the default prints out the number with the factorial. Hopefully, this can help you set up your program, with the switch statement. Good luck.
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
52
53
54
55
#include <iostream>

using namespace std;

int factorial (int);
void rules();

int main()
{
	int result;
	
	cout << "Enter your number: ";
	cin >> result;
	
	switch(result)
	{
		case 1:
		case 2:
			rules();
			break;
		case 3:
			cout << "The factorial of three is "<< factorial (result);
			break;
		case 4:
			cout << "The factorial of four is "<< factorial (result);
			break;
		case 5:
			cout << "The factorial of five is "<< factorial (result);
			break;
		case 6:
			cout << "The factorial of six is "<< factorial (result);
			break;
		case 7:
			cout << "The factorial of seven is "<< factorial (result);
			break;
		default:
			cout << "Factorial of " << result << " is "<< factorial (result) << endl;
	}
	cout << endl << endl;
}

void rules()
{
	cout << "A one or two, returns the same values inputted." << endl <<"Next time, try a higher number..";
}

int factorial (int n)
{
	int fact = 0;
	if (n <= 1)
		return 1;
	else
		fact = n * factorial (n - 1);
	return fact;
}
Topic archived. No new replies allowed.