A menu run-time error code, help please!

I'm getting a run-time error where if I enter '2 2' for the first cin, it says y variable is being used without being initialized, then if I enter '3 2' at the second cin, it says the w variable is being used without being initialized. I don't know why it's showing those. Help and thanks in advance!
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  //menu
#include <iostream>    //Important stuff
#include <iomanip>
#include <string>
using namespace std;

int main ()     //Defining variables for codes to work
{
	int a,
		b,
		c,
		d,
		item1,
		item2,
		item3,
		item4,
		w,
		x,
		y,
		z;
	const double Salad1 = 4.50,
		Soup1 = 8.50,
		Chicken1 = 11.00,
		Cheesecake1 = 5.00,
		tax = 1.09;
		double total1,
		total2,
		total3,
		total4;
		string item5;

	//Having the customer pick how many of something they want
	//First we tell them what we had then ask them how many of those they want.
	//Then we use cin as a way to plug in the number to use later for the bill.
	cout << "Welcome to CSUF dinings, here is our menu." << endl;
	cout << "1. Salad - $4.50" << endl; 
	cout << "2. Soup - $8.50" << endl;
	cout << "3. Chicken - $11.00" << endl;
	cout << "4. Cheesecake - $5.00" << endl;
	cout << "Enter in the number you would like to order. And how many of it would you like?" << endl;
	cin >> item1 >> a;
	if (item1 == 1)
	{total1 = Salad1*a;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total1 << endl;
		item5 = "Salad";
		w = a;
	}
	else if (item1 == 2)
	{total1 = Soup1*a;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total1 << endl;
		item5 = "Soup";
		x = a;
	}
	else if (item1 == 3)
	{total1 = Chicken1*a;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total1 << endl;
		item5 = "Chicken";
		y = a;
	}
	else if (item1 == 4)
	{total1 = Cheesecake1*a;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total1 << endl;
		item5 = "Cheesecake";
		z = a;
	} 

	cout << "What else would you like? Enter in the number you would like to order. And how many of it would you like? If you are done ordering, enter in 5 and 0." << endl;
		cout << "1. Salad - $4.50" << endl; 
	cout << "2. Soup - $8.50" << endl;
	cout << "3. Chicken - $11.00" << endl;
	cout << "4. Cheesecake - $5.00" << endl;
	cin >> item2 >> b;
	if (item2 == 1)
	{total2 = Salad1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total2 << endl;
		w += b;
	}
	else if (item2 == 2)
	{total2 = Soup1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total2 << endl;
		x += b;
	}
	else if (item2 == 3)
	{total2 = Chicken1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total2 << endl;
		y += b;
	}
	else if (item2 == 4)
	{total2 = Cheesecake1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total2 << endl;
		z += b;
	} 
	else if (item2 == 5)
		{cout << "You ordered " << a << " number of " << item5 << "." << endl;
			cout << "Your total will be $" << setprecision(2) << fixed << (total1)*tax << endl;
	cout << "Thanks for ordering at CSUF dinings, and have a nice day!" << endl;
	cout << "You ordered " << w << " salads." << endl;
	
	return 0; 
	}

	cout << "What else would you like? Enter in the number you would like to order. And how many of it would you like? If you are done ordering, enter in 5 and 0." << endl;
		cout << "1. Salad - $4.50" << endl; 
	cout << "2. Soup - $8.50" << endl;
	cout << "3. Chicken - $11.00" << endl;
	cout << "4. Cheesecake - $5.00" << endl;
	cin >> item3 >> c;
	if (item3 == 1)
	{total3 = Salad1*c;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total3 << endl;
	}
	else if (item3 == 2)
	{total3 = Soup1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total3 << endl;
	}
	else if (item3 == 3)
	{total3 = Chicken1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total3 << endl;
	}
	else if (item3 == 4)
	{total3 = Cheesecake1*b;
		cout << "Your total so far will be $" << setprecision(2) << fixed << total3 << endl;
	} 
	else if (item3 == 5)
	{
		if (w >= 1)
		{
		cout << "You ordered " << w << " salads." << endl;
		}
		cout << "Your total will be $" << setprecision(2) << fixed << (total1+total2)*tax << endl;
	cout << "Thanks for ordering at CSUF dinings, and have a nice day!" << endl;

	return 0;
	}

		return 0;
}





I tried this program in my computer, and it works fine.
Perhaps setting initial value to those 'ints' could resolve it.

int a = 0, b = 0, c = 0, d = 0, ...

Thanks, that solved my problem! Also, do you know how to set it so when the user is done ordering, they don't need to enter in '5 0' , but just enter a single digit to end? Thanks!
Topic archived. No new replies allowed.