User Interface Help!!!!!

Hi i just started learning c++ and im trying to make a very basic user interface.
im using if loops to let the user input data and be able to choose different paths. This is it so far i still need to finish the last options. It gives me an error when im trying to run it and im not sure what it is. Please teach me dont just give me the answer.

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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <iostream>
using namespace std;

//////////////////////////////////////////////////////////
//Test For UI/////////////////////////////////////////
//controlls: Lights, Doors, Windows, electronics///
///////////////////////////////////////////////
int main(int argc, char *argv[]) {
	int a, b, c, d, e, f;
	int b1, b2, b3, b4, b5, b6, b7, b8, b9, b10;
	
	
	cout << "welcome!\nLights (1), Doors (2), Windows (3), Electronics (4)\n";
	cin >> b;
////////////////////////////////////////////////////////////////////////////////
//Light Choices/////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////	
	if (b = 1) {
		cout << "|Lights|\n";
		cout << "livingroom (1), Hallway (2), Kitchen (3), Bathroom (4), Room 1 (5), Room 2 (6)\n";
		cin >> b1;
		////////////////////////////////////////////////////////////////////////
		//|Livingroom|//////////////////////////////////////////////////////////
		////////////////////////////////////////////////////////////////////////
		if (b1 = 1){
			cout << "|Livingroom|\n";
			cout << "Corner Lamp (1), Back Lights(2)\n";
			cin >> b2;
			//Corner Lamp///////////////////////////////////////////////////////
			if (b2 = 1) {
				cout << "|Corner Lamp|\n";
				cout << "On (1), Off (2)\n";
				cin >> b3;
				//On////////////////////////////////////////////////////////////
				if (b3 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b3 = 2) {
					cout << "Lights Off!";
				}
			}
			//Back Lights///////////////////////////////////////////////////////
			if (b2 = 2) {
				cout << "|Back Lights|\n";
				cout << "On (1), Off (2)\n";
				cin >> b4;
				//On////////////////////////////////////////////////////////////
				if (b4 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b4 = 2) {
					cout << "Lights Off!";
				}
			}
		}
		////////////////////////////////////////////////////////////////////////
		//|Hallway|/////////////////////////////////////////////////////////////
		////////////////////////////////////////////////////////////////////////
		if (b1 = 2){
			cout << "|Hallway|\n";
			cout << "Enterence Light (1), Main Lights (2)\n";
			cin >> b5;
			//Corner Lamp//////////////////////////////////////////////////////
					cout << "Lights Off!";
				cout << "|CMain Light|\n";
				cout << "On (1), Off (2)\n";
				cin >> b6;
				//On////////////////////////////////////////////////////////////
				if (b6 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b6 = 2) {}
			}
				}
			if (b5 = 1) {}
			//Main Lights///////////////////////////////////////////////////////
			if (b5 = 2) {
				cout << "|Main Lights|\n";
				cout << "On (1), Off (2)\n";
				cin >> b6;
				//On////////////////////////////////////////////////////////////
				if (b6 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b6 = 2) {
					cout << "Lights Off!";
				}
			}
		}
		////////////////////////////////////////////////////////////////////////
		//|Kitchen|/////////////////////////////////////////////////////////////
		////////////////////////////////////////////////////////////////////////
		if (b1 = 3){
			cout << "|Kitchen Lights|\n";
			cout << "Main Light (1), Table Light(2)\n";
			cin >> b7;
			//Main Light////////////////////////////////////////////////////////
			if (b7 = 1) {
				cout << "|Main Light|\n";
				cout << "On (1), Off (2)\n";
				cin >> b8;
				//On////////////////////////////////////////////////////////////
				if (b8 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b8 = 2) {
					cout << "Lights Off!";
				}
			}
			//Back Lights///////////////////////////////////////////////////////
			if (b9 = 2) {
				cout << "|Back Lights|\n";
				cout << "On (1), Off (2)\n";
				cin >> b10;
				//On////////////////////////////////////////////////////////////
				if (b10 = 1) {
					cout << "Lights On!";
				}
				//Off///////////////////////////////////////////////////////////
				if (b10 = 2) {
					cout << "Lights Off!"
				}
			}
		}
		}
////////////////////////////////////////////////////////////////////////////////
//Door Choices//////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
	if (b = 2) {
		cout << "|Doors|\n";
		cout << "livingroom (1), Bathroom (2), Room 1 (3), Room 2 (4) Balcony (5)\n";
		cin >> d;
	}
////////////////////////////////////////////////////////////////////////////////
//Window Choices////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
	if (b = 3) {
		cout << "|Windows|\n";
		cout << "Kitchen (1), Room 1 (2), Room 2 (3)\n";
		cin >> e;
	}
////////////////////////////////////////////////////////////////////////////////
//Electronics Choices///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
	if (b = 4) {
		cout << "|Electronics|\n";
		cout << "livingroom (1), Kitchen (2), Bathroom (3), Room 1 (4), Room 2 (5)\n";
		cin >> f;
	}


	return 0;
}
Inside all of your if statements, you need to use == (comparison operator) instead of = (assignment operator). For example, line 10 should be if (b == 1).

Consider using switch() statements instead of a series of if's.

Consider using functions. It will make the code cleaner. For example (with if statements in case you haven't learned switch):
1
2
3
4
5
6
7
8
9
10
11
 if (b ==1) {
    doLights();
} else if (b == 2) {
    doDors();
} else if (b == 3) {
    doWindows();
} else if b == 4) {
    doElectronics();
} else {
    cout << "Invalid entry " << b << '\n';
}

Thanks i fixed the "==" problem . im learning switch right now.
Topic archived. No new replies allowed.