not asking second question in my code

Hi, I am trying to write a program at work for the first time. Basically I need to have a simple program that allows a person to enter the OU group name and the City/area. Then a list of names of techs they can assign a ticket to comes up. What I'm having an issue with is after I enter the OU in testing it jumps over the city question and pops up with a tech name. I need to have it request both questions answered. Where am I going wrong in my code? I've stared at it for a while... :)

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
  #include <iostream>
using namespace std;

int main()
{
//variables
	int texas =1, denver=2, midland=3, dallas=4, houston=5;
	int wsl=101, ucb=102, ucs=103, wls=104;
	int ou;
	int area;

//statement
	cout << "Please enter the ticket OU: "<<endl;
	cin >> ou;
	cout <<endl;
	cout << "Please enter the city the ticket originates from: " <<endl;
	cin >> area;
	cout << endl << endl;

//decision loop
	while (true)
	{
		if (ou == wsl && area == texas, denver, midland, dallas, houston )
			{
			cout << "Your tech is Michael McDonald."<<endl;
			break;
			}
		
		if (ou == wls && area == texas, denver, midland, dallas, houston)
			{
			cout << "Your tech is Michael McDonald." <<endl;
			break;
			}

		if (ou == ucb && area == texas, denver, midland, dallas, houston)
			{
			cout << "Your tech is Michael McDonald." <<endl;
			break;
			}

		if (ou == ucs && area == texas, denver, midland, dallas, houston)
			{
			cout << "Your tech is Michael McDonald." <<endl;
			break;
			}
	}

//end of program
	system ("pause");
	return 0;
}
Last edited on
closed account (E0p9LyTq)
I get asked two questions when I run your program:

Please enter the ticket OU:
103

Please enter the city the ticket originates from:
2


Your tech is Michael McDonald.


Using TDM-GCC 4.9.2
I was entering Houston and wsl for example. I see.... thanks FurryGuy.
closed account (E0p9LyTq)
A couple of things stand out that make debugging your program a bit difficult.

No matter which if statement is triggered you are outputting the exact same text. Change the text so you know explicitly which if statement trips. If I were doing this I'd change the text to read something like "Tech One", "Tech Two", etc.

Why are you separating the cities when you compare area? I get a lot of warnings when I compile using TDM-GCC 4.9.2:

23	17	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] left operand of comma operator has no effect [-Wunused-value]
23	43	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
23	52	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
23	60	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
29	17	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] left operand of comma operator has no effect [-Wunused-value]
29	43	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
29	52	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
29	60	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
35	17	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] left operand of comma operator has no effect [-Wunused-value]
35	43	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
35	52	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
35	60	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
41	17	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] left operand of comma operator has no effect [-Wunused-value]
41	43	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
41	52	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
41	60	C:\Users\Public\Documents\My Projects\main.cpp	[Warning] right operand of comma operator has no effect [-Wunused-value]
Topic archived. No new replies allowed.