basic 4 slot seat reservation

hello, i'm trying to program a 4 slot restaurant table code with a bool loop. I do not know how to make it so that if someone selects seat 1, the loop repeats but eliminates option seat 1 because it is already taken, and so on until it all seats are selected. I also have a problem because no matter what input i put for "what seat number?" it always outputs "seat1". I am also having trouble in that once a seat is selected, a request for a name appears. i want on the right hand side of the selection to show
"[...1...|...2...]
[...3...|...4...]"

but as the names are added per chosen seat, it automatically reflects the change.

here is my basic code, without the loop, and only selection of 1 seat option, then asks all names, then reflects values.:

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

using namespace std;
int main()
{

	
string seatnum;{			

	std::cout << "What seat number?\n";//shows seat arrangement
	std::cout << "[..1..|..2..]\n";
	std::cout << "[--3--|--4--]\n";
std::getline(cin, seatnum);  //logic boolean if then seat readout (need to edit to add names per selection)
if (bool seatnum="1")
std::cout << "seat1=\n";
else if (bool seatnum="2")
std::cout << "seat2=\n";
else if (bool seatnum=3)
std::cout << "seat3=\n";
else if (bool seatnum=4)
std::cout << "seat4=\n";
 
//no matter what selection, it always outputs seat1
}
	
	
		string name;{				//names
			std::cout  <<  "Name?";		//asks name
			std::getline(cin,name);}		//input

		string nametwo;{
			std::cout  <<  "Name?";
			std::getline(cin,nametwo);}

		string namethree;{
			std::cout  <<  "Name?";
			std::getline(cin,namethree);}

		string namefour;{
			std::cout  <<  "Name?";
			std::getline(cin,namefour);}
		{
			//end summary (needs edit)  make table
			///SN#/name

			///SN#x/namex/

			//SN#y/namey/

			//SN#z/namez

			//  show diagram summary in correspondence
	std::cout << "Table:"  << endl <<  "seat number:" << seatnum <<endl  << "Name:"  << name <<endl;
	std::cout << "[.." << name <<"..|.." << nametwo <<"..]\n";
	std::cout << "[.." << namethree << "..|.." << namefour <<"..]";
	//  projected final function: selection of seat, enter name, auto changes diagram, reverse/edit names

// break point here, console auto-closes
	
	return 0;
}
}

1
2
3
4
5
6
7
8
if (bool seatnum="1")
std::cout << "seat1=\n";
else if (bool seatnum="2")
std::cout << "seat2=\n";
else if (bool seatnum=3)
std::cout << "seat3=\n";
else if (bool seatnum=4)
std::cout << "seat4=\n";


Your problems are your conditions.
bool seatnum = "1" returns a 1 as a successful assignment has taken place.
What you want is:
(seatnum == "1") which is an actual Boolean expression. '==' is compare, '=' is assign.
bool loop? Never heard of it.

seatnum also has dual definitions, as a string and as a bool. You also define the bool value directly in the condition for the if statement, as well as initialize it. You could likely change it to an int and the user enters either 1, 2, 3, 4.

You already use the entire std namespace, you don't need the std::. This won't flag an error, just saying that it's pointless.

1
2
//no matter what selection, it always outputs seat1
}


Well, the seat1 deal is due to the improper definition of seatnum. The brace after ends the main function.
ok! i got it down! turns out it was in the next chapter of my book.

here's the code:
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
#include <iostream>
#include <string>
using namespace std;

int n;
 string name;
 string nametwo;
 string namethree;
 string namefour;

int main()
{
	loop:

	std::cout << "What seat number?\n";//shows seat arrangement
	std::cout << "[..1..|..2..]\n";
	std::cout << "[--3--|--4--]\n";
	std::cin >> n; 

 //logic boolean if then seat readout (need to edit to add names per selection)

if(n==1){
	std::cout << "seat1=\n";      //first seat selected, then asks for name.
	std::cout  <<  "Name?";
	cin >> name;}
else if(n==2){
	std::cout << "seat2=\n";}
else if(n==3){
	std::cout << "seat3=\n";}
else if (n==4){
	std::cout << "seat4=\n";}

//loop if invalid number is entered
do{


if(n<1||n>4){
cout << "please enter valid seat number.\n";goto loop;
}
else break;
}
while(n<1||n>4); 
	
		//work in progress, see first seat selected for example
			
		

			std::cout  <<  "Name?";
			cin >> nametwo;

		
			std::cout  <<  "Name?";
			cin >> namethree;

		
			std::cout  <<  "Name?";
			cin >> namefour;
			//end summary (needs edit)  make table
			///SN#/name

			///SN#x/namex/

			//SN#y/namey/

			//SN#z/namez

			//  show diagram summary in correspondence
	std::cout << "Table:"  << endl <<  "seat number:" << n <<endl  << "Name:"  << name <<endl;
	std::cout << "[.." << name <<"..|.." << nametwo <<"..]\n";
	std::cout << "[.." << namethree << "..|.." << namefour <<"..]";
	//  projected final function: selection of seat, enter name, auto changes diagram, reverse/edit names

// break point here, console auto-closes.  can someone help with that pls?
	
	return 0;
}


My question is: how can i do a loop that when you enter the seat number and name, it loops back, but eliminates the already chosen seats? repeating until all seats are chosen, then final output.
Topic archived. No new replies allowed.