Switch statement

Hi,
I found an exercise online where and i almost finished it but when the final message is displayed the cmd window closed.

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
#include <iostream>
#include <Windows.h>

using namespace std;



int main()
{

	SetConsoleTitle("Cola Machine");

	cout << "Welcome to this cola machine.\n"
		"We have a few beverages you can choose from.\n"
		"1 = Cola, 2 = Sprite, 3 = Fanta, 4 = Water, 5 = Chocolate milk.\n" << endl;

	int userChoise;

	cin >> userChoise;
	
	switch (userChoise)
	{
	case 1:
		cout << "You chose the Cola.";
		break;
	case 2:
		cout << "You chose the Spirte.";
		break;
	case 3: 
		cout << "You chose the Fanta.";
		break;
	case 4: 
		cout << "You chose the Water.";
		break;
	case 5: 
		cout << "You chose the Chocolate milk";
		break;
	default :
		cout << "Error. choice was not valid, here is your money back.";
		break;
	
	}
	
	cin.get();

	return 0;
}
Last edited on
Do either:
1) Configure your IDE properly so it would keep window open.
2) Run program from command line directly.
HI,

See the topic that is sticky posted at the top of the beginners section.
MiiNiPaa,

Thx for the anwser!

TheIDeasMan,

Sorry didnt see that one.
Topic archived. No new replies allowed.