This is the only error I keep getting. Why?

The program exercise:

section A: $20/300 seats
Section B: $15/500 seats
Section C: $10/200 seats

Design program that asks for number of tickets sold in each section & displays amount of income generated from ticket sales. Program should validate the numbers that are entered for each section.






code:



int main()
{
int A, B, C;
int TotalIncome;

cout << "Enter number of seats sold in Section A: \n";
cin >> A;

cout << "Enter number of seats sold in Section B: \n";
cin >> B;

cout << "Enter a number of seats sold in Section C: \n";
cin >> C;

while (A < 0 or A > 300)
{
cout << "ERROR: Seats sold in Section A cannot be \n";
cout << "greater than 300 or negative.\n ";

cout << "Enter valid value for seats sold in section A: \n";
cout << "A value in the range of 0 to 300 inclusive. \n";
cin >> A;

while (B < 0 or B > 500)
{
cout << "ERROR: Seats sold in Section B cannot be \n";
cout << "greater than 500 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 500 inclusive. \n";
cin >> B;

while (C < 0 or C > 200)
{
cout << "ERROR: Seats sold in Section C cannot be \n";
cout << "greater than 200 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 200 inclusive. \n";
cin >> C;

Set TotalIncome = (A * 20) + (B * 15) + (C * 10);

cout << "The total income generated from ticket sales \n ";
cout << "of all sections is $ ", << TotalIncome << endl;

}
}
}
}


Error Message:

F:\CH7Q2Theater.cpp||In function 'int main()':|
Line |68|error: expected primary-expression before '<<' token|
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
int main()
{
int A, B, C;
int TotalIncome;

cout << "Enter number of seats sold in Section A: \n";
cin >> A;

cout << "Enter number of seats sold in Section B: \n";
cin >> B;

cout << "Enter a number of seats sold in Section C: \n";
cin >> C;

while (A < 0 or A > 300)
{
cout << "ERROR: Seats sold in Section A cannot be \n";
cout << "greater than 300 or negative.\n ";

cout << "Enter valid value for seats sold in section A: \n";
cout << "A value in the range of 0 to 300 inclusive. \n";
cin >> A;

while (B < 0 or B > 500)
{
cout << "ERROR: Seats sold in Section B cannot be \n";
cout << "greater than 500 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 500 inclusive. \n";
cin >> B;

while (C < 0 or C > 200)
{
cout << "ERROR: Seats sold in Section C cannot be \n";
cout << "greater than 200 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 200 inclusive. \n";
cin >> C;

Set TotalIncome = (A * 20) + (B * 15) + (C * 10);

cout << "The total income generated from ticket sales \n ";
cout << "of all sections is $ ", << TotalIncome << endl;

}
}
}
}


Get rid of the comma in the bolded line.
Last edited on
Thank you.. Its always the small things...


Also what would I need to do to have line 45 return a value?

I can enter the amount of seats sold but it returns a 0.

When I enter the wrong amounts it prompts me to answer the right numbers and totals the dollar amount.


Last edited on
All of the close curly brackets at the end of the code need to be put immediately after the cin for each while statement. I believe you also need to remove the word "Set" from the line Set TotalIncome = (A * 20) + (B * 15) + (C * 10);

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
int main()
{
int A, B, C;
int TotalIncome;

cout << "Enter number of seats sold in Section A: \n";
cin >> A;

cout << "Enter number of seats sold in Section B: \n";
cin >> B;

cout << "Enter a number of seats sold in Section C: \n";
cin >> C;

while (A < 0 or A > 300)
{
cout << "ERROR: Seats sold in Section A cannot be \n";
cout << "greater than 300 or negative.\n ";

cout << "Enter valid value for seats sold in section A: \n";
cout << "A value in the range of 0 to 300 inclusive. \n";
cin >> A;
}

while (B < 0 or B > 500)
{
cout << "ERROR: Seats sold in Section B cannot be \n";
cout << "greater than 500 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 500 inclusive. \n";
cin >> B;
}

while (C < 0 or C > 200)
{
cout << "ERROR: Seats sold in Section C cannot be \n";
cout << "greater than 200 or negative.\n ";

cout << "Enter valid value for seats sold in section C: \n";
cout << "A value in the range of 0 to 200 inclusive. \n";
cin >> C;
}

TotalIncome = (A * 20) + (B * 15) + (C * 10);

cout << "The total income generated from ticket sales \n ";
cout << "of all sections is $ " << TotalIncome << endl;

}


The code would look like that when you're done. This way the line TotalIncome = (A * 20) + (B * 15) + (C * 10); takes place after each while statement is completed.
Last edited on
This line won't compile for me. You don't need the "set" at the beginning of the assignment statement.

Set TotalIncome = (A * 20) + (B * 15) + (C * 10);
Thank you... Still learning and probably would have sat here another hour beating my head in..
Topic archived. No new replies allowed.