Really Need Help...please...

First of all, I am total new to c++ and far from being expert, so I really need help to complete my task and improve my skill.Everything in the source code is working fine, but once I want to print the bill, it wouldn't show because it will said that the name I input is invalid.

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

#include <conio.h>
using namespace std;

string roomType;
int roomNumber;
int bed;
int table;
int towel;
int sofa;
string name;
int phone;
int id;
int choice; 

class Node
{
public:

	string roomType;
	int roomNumber;
	string name;
	
	int phone;
	int bed;
	int table;
	int towel;
	int sofa;
	Node *next;
	int id;
	 

	Node(int x, string a, int b, int c, int d, int e, int i, string n, Node *z)
	{
		roomType = a;
		roomNumber = x;
		bed = b;
		table = c;
		towel = d;
		sofa = e;
		next = z;
		name = n; 
		id = i; 
	}
};

class user
{
public:
	int id;
	string name;
	user *next;
	int phone;

	user(int i, string y, user *z, int b) //COnstructor witn parameter
	{
		id = i; 
		name = y;
		next = z;
		phone = b;

	}
};

class Room
{
private:
	Node *head;
	Node *first; 
	int count;
public:
	Room();//Room(DoubleRoom);
	
	void Menu();
	void roomtype(int);
	void addRoom();
	void deleteRoom(int x);
	void viewRoom();
	void editRoom();
	void searchRoom();
	void printRoom();

};

class Roomtype : Room
{
private:
	Node *head;
public:
	Roomtype();
	string single();
	string doubl();
	string supreme();

};
 



Room.cpp
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314

#include <iostream>
#include <iomanip>
#include <string>
#include <conio.h>
#include "Room.h" 
using namespace std;
Room::Room()
{
	head = NULL;
	int count = 0;
}
void Room::Menu()
{
	cout << "Welcome to Virtual Architecture" << endl;
	cout << "**************************" << endl;
	cout << "**" << endl;
	cout << "**-------MENU------**" << endl;
	cout << "** 1. Add room     **" << endl;
	cout << "** 2. Drop room    **" << endl;
	cout << "** 3. View data    **" << endl;
	cout << "** 4. Edit data    **" << endl;
	cout << "** 5. Search Room  **" << endl;
	cout << "** 6. Print Room   **" << endl;
	cout << "** 7. Exit         **" << endl;
	cout << "**-----------------**" << endl;

	cout << "Please select your choice: " << endl;
}
void Room::addRoom()
{
	cout << "Please enter your information: " << endl;
	cout << " Enter Your Id  = ";
	cin >> id;
	cout << " Enter Your Name = ";
	cin >> name;
	cout << " Enter Your Phone Number = ";
	cin >> phone;
	cout << " Room type" << endl;
	cout << "\n1.single\n2.double\n3.supreme\n:";
	cin >> roomType;
	cout << "Room Number ";
	cin >> roomNumber;
	cout << "No of bed: ";
	cin >> bed;
	cout << "No. of Table: ";
	cin >> table;
	cout << "No. of Towel: ";
	cin >> towel;
	cout << "No. of Sofa: ";
	cin >> sofa;
	cout << "Room Registered." << endl;
	Node *p;
	if (head == NULL)
	{
		head = new Node(roomNumber, roomType, bed, table, towel, sofa, id, name, NULL);
	}
	else
	{
		p = head;
		while (p->next != NULL)
			p = p->next;
		p->next = new Node(roomNumber, roomType, bed, table, towel, sofa, id, name, NULL);
	}
	//count ++;
}
void Room::deleteRoom(int x)
{
			
	Node *del = NULL;
	Node *temp = head;
	Node *second = head;

	while (second != NULL && ((*second).roomNumber) != roomNumber)
	{
		temp = second;//let temp point to watever end is pointed to
		second = (*second).next;
	}

	if (second == NULL)
	{
		cout << roomNumber << " No Data Deleted" << endl;
		delete del;//free memory;
	}

	else
	{
		del = second;
		second = (*second).next;
		(*temp).next = second;

		if (del == head)
		{
			head = (*head).next;
			temp = NULL;
		}

		delete del;
		cout << "The value " << x << " was deleted." << endl;
	}

}
void Room::viewRoom()
{
	Node *second;
	second = head;
	while (second != NULL)
	{
		cout << "ID Number" << "    " << "Name" << "	" << "Room Number" << endl;
		cout << setfill('x') << setw(5);
		cout << (*second).id << "	";
		cout << setfill(' ') << setw(10);
		cout << (*second).name << "	";
		cout << setfill(' ') << setw(10);
		cout << (*second).roomNumber << "	";
		second = (*second).next;
		cout << "\n";
		//system("pause");
		//system("cls");
	}
}
void Room::editRoom()//This function is to edit customer details in the system
{
	int editing = 0; int typee = 0;
	Node *second = head;
	cout << " Enter id: ";
	int id;
	cin >> id;
	while (second != NULL && (second->id) != id)
	{
		second = second->next;
	}
	if (second == NULL)
	{
		cout << id << " No Data Edited" << endl;
		return;
	}
	cout << " 1.Edit Name\n 2.Edit Phone Number";
	cin >> typee;
	if (typee == 1)
	{
		cout << " Enter Your New Name : " << endl;
		string newname;
		cin >> newname;
		second->name = newname;
		cout << " The name for id number " << id << " was edited." << endl;
	}
	if (typee == 2)
	{
		cout << "Please Enter Your New Phone Number";
		int newhp;
		cin >> newhp;
		while (second != NULL && (second->id) != id)
		{
			second = second->next;
		}
		if (second == NULL)
		{
			cout << id << " No Data Edited" << endl;
		}
		else
		{
			second->phone = newhp;
			cout << "The contact number for id number " << id << " was edited." << endl;
		}
	}
}
//------------------------------------------------==SEARCH FUNCTION==------------------------------------------------------------------------
void Room::searchRoom()
{
	int id;
	Node *p;
	cout << "Enter ID: ";
	cin >> id;
	p = head;
	bool found = false;
	while (p != NULL)
	{
		if (p->id == id) {
			cout << "Customer's Name" << "    " << "Room Number" << "	" << endl;
			cout << setfill(' ') << setw(10);
			cout << (*p).name << "	";
			cout << setfill(' ') << setw(5);
			cout << (*p).roomNumber << "	";

			cout << "\n";
			found = true;
		}
		p = (*p).next;
	}
	if (found == false)
		cout << "The ID is not in the list" << endl;
	system("pause");
	system("cls");
}
//------------------------------------------------==Print FUNCTION==------------------------------------------------------------------------
void Room::printRoom()
{
	int choice, count = 1, count1 = 1;
	Node *second;
	second = head;
	cout << "Enter Name to print Receipt: " << endl;
	cin >> name;

	cout << " " << endl;
	while (second != NULL && (second->name) != name)
	{
		count++;
		second = head->next;
	}
	if (second == NULL)
	{
		cout << "\t\t ***<-- Receipt on Virtual Architecture -->***\n" << endl;
		cout << "         ||Customer's Name: \n       ||" << second->name;
		cout << "         ||Customer Phone Number : \n||" << second->phone;
		cout << "___________________________________________________________________" << endl;
		cout << "Room Type\tBed\tTable\t\towel \t\sofa" << endl;
		cout << "___________________________________________________________________" << endl;
		cout << second->roomType << "\t\t" << second->bed << "\t\t    " << second->table << "\t\t" << second->towel << "\t\t" << second->sofa << endl;
		second = second->next;
		while (second != NULL && (second->name) == name)
		{
			cout << second->roomType << "\t\t" << second->bed << "\t\t    " << second->table << "\t\t" << second - sofa << endl;
			count1++;
			second = second->next;
		}
	}
	else
	{
		cout << "Error. Enter a valid name." << endl;
	}
}
int main()
{
	Room a1;
Main:
	a1.Menu();
	int choice = 0;
	cin >> choice;
	switch (choice)
	{
	case 1:
		system("cls");
		a1.addRoom();
		system("pause");
		system("cls");
		goto Main;
		break;
	case 2:
		system("cls");
		cout << "Enter Room Number: ";
		cin >> roomNumber;
		char a;
		cout << "Are you sure you want to drop this events? (y/n)" << endl;
		cin >> a;
		if (a == 'N' || 'n')
		{
			a1.deleteRoom(roomNumber);
			system("pause");
			system("cls");
			goto Main;
		}
		else if (a == 'Y' || 'y')
		{
			system("cls");
			goto Main;
		}
		else
		{
			cout << "Invalid input.\nPlease try again." << endl;
			fflush(stdin);
			cin.clear();
			goto Main;
		}
		break;
	case 3:
		system("cls");
		a1.viewRoom();
		system("pause");
		system("cls");
		goto Main;
		break;
	case 4:
		system("cls");
		a1.editRoom();
		system("pause");
		system("cls");
		goto Main;
		break;
	case 5:
		system("cls");
		a1.searchRoom();
		system("pause");
		system("cls");
		goto Main;
		break;
	case 6:
		system("cls");
		a1.printRoom();
		system("pause");
		system("cls");
		goto Main;
		break;
	case 7:
		break;
	default:
		cout << "Invalid input.\nPlease try again." << endl;
		fflush(stdin);
		cin.clear();
		system("pause");
		goto Main;
		break;
	}
}


and I got two warnings that I don't really understand

warning C4129: 's' : unrecognized character escape sequence
warning C4101: 'choice' : unreferenced local variable
warning C4101: 'choice' : unreferenced local variable

You repeatedly create a variable named choice. At least once, you're creating one and never using it.


cout << "Room Type\tBed\tTable\t\towel \t\sofa" << endl;
See that "\s"? Putting a slash in front of the s like that makes it a special character, called an "escape sequence". However, it's invalid. There's no such escape sequence as "\s". I expect you meant this:
cout << "Room Type\tBed\tTable\t\towel \tsofa" << endl;
Oh, I see, I change the second warning and I have no problem with it anymore
But when I delete 'choice' it still didn't print out the receipt and keep saying that the ID is invalid
How do I fix that?
Last edited on
Here is how you can ask that last question so that we can help you:

Of the code as you see it above, I made exactly these changes:

List of changes

I then compiled it. I saw this many warnings, which were as follows:

List of warnings

I saw this many errors, which were as follows:

List of errors

I ran the program. I gave this input:

Complete input I gave

I saw this output:

What I saw on the screen

I was expecting this:

Description of what I wanted to see

Why did it not do what I expected?
Last edited on
Solve the problem already last night
Thank you for your great help though
Thank you very much
Topic archived. No new replies allowed.