Constantly repeating

Hello, I'm missing something very simple here. I would appreciate it if someone could tell me what exactly it is. As a training exercise I am writing up a quick function which asks what kind of soda you'd like to choose etc. Regardless when I run it, It constantly repeats it self. May have something to do with the answer being letters rather than numbers, not sure.

After that on-going typing here is the class

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>

//@author Will A Cola Machine Training Exercise

int main()
{

	int soda = 0;
	int cocacola = 0;
	int sprite = 0;
	int pepsi = 0;
	int drpepper = 0;
	bool repeat = true;


	while(repeat)
		{
			std::cout<<"Soda Machine ||| Created By Will A.\n      Inspired By BlitzCoder";

			std::cout<<"\n\n\n\nPlease Enter CocaCola, Sprite, Pepsi or DrPepper:\n\n";
			std::cin>>soda;

			if((cocacola))
			{
				std::cout<<"\n\n\nYou recieve a can of Coca-Cola!\n";
			}
			else if((sprite))
			{
				std::cout<<"\n\n\nYou recieve a can of Sprite!\n";
			}
			else if((pepsi))
			{
				std::cout<<"\n\n\nYou recieve a can of Pepsi!\n";
			}
			else if((drpepper))
			{
				std::cout<<"\n\n\nYou recieve a can of DrPepper!\n";
			}
			else 
			{
				std::cout<<"Please choose the following!\nEnter CocaCola, Sprite, Pepsi or DrPepper:\n\n";
			}


		}

}


-Will
std::string soda; will do the trick


then:
1
2
3
4
if (soda=="pepsi") 
{
cout << "lala";
}


Use string when you want to enter words
Last edited on
Okay, thanks.

I appreciate it.
How do you print screen and display code link that ?
@ IceyEyez
How to use code tags: http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.