Wrong std_out value?

Hi guys, I am doing this problem for homework, and there is one error that I don't know how to fix.

Assume  that an int variable  age has been declared  and already  given  a value  and assume  that a char variable  choice has been declared  as well. Assume  further that the user has just been presented with the following menu:

S: hangar steak, red potatoes, asparagus
T: whole trout, long rice, brussel sprouts
B: cheddar cheeseburger, steak fries, cole slaw
(Yes, this menu really IS a menu!)

Write some code that reads a single character  (S or T or B) into choice . Then the code prints out a recommended accompanying drink as follows:

If the value  of age is 21 or lower, the recommendation is "vegetable juice" for steak, "cranberry juice" for trout, and "soda" for the burger. Otherwise, the recommendations are "cabernet", "chardonnay", and "IPA" for steak, trout, and burger respectively. Regardless of the value  of age , your code should print "invalid menu selection" if the character  read into choice was not S or T or B.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  cin >> choice;

if (choice == 'S')
{if (age <= 21)
cout << "vegetable juice";
cout << "cabernet";}

else if (choice == 'T')
{if (age <= 21)
cout << "cranberry juice";
cout << "chardonnay";}

else if (choice == 'B')
{if (age <= 21)
cout << "soda";
cout << "IPA";}

else
cout << "invalid menu selection";


It says "The value of _stdout is incorrect.", so what did I do wrong? :O
It says "The value of _stdout is incorrect.", so what did I do wrong? :O

I personally can't tell what the problem is, from the code that you posted.
What I do see is that you probably missed some else branches.

Also you should invest a bit of time into learning an indentation style (which makes it easier to read 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
    cin >> choice;

    if (choice == 'S')
    {
        if (age <= 21)
            cout << "vegetable juice";
        else // branch missing?
            cout << "cabernet";
    }
    else
    if (choice == 'T')
    {
        if (age <= 21)
            cout << "cranberry juice";
        else // branch missing?
            cout << "chardonnay";
    }
    else
    if (choice == 'B')
    {
        if (age <= 21)
            cout << "soda";
        else // branch missing?
            cout << "IPA";
    }
    else
        cout << "invalid menu selection";


So please, post the entire source code of your program.
Got it. Thank you very much. :)
Topic archived. No new replies allowed.