Question: Hi there, I am trying to code this program in C and I am not able to get it to work for my homework. I

Hi there, I am trying to code this program in C and I am not able to get it to work for my homework. I feel like Ive tried everything, I will for sure thumbs up if you can help me figure out what is wrong. Here is the problem as well as what I have:

Hi there, I am trying to code this program in C and

Here is the error and suggestions to fix:

I am not able to get it to work for my homework.

Thank you!

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. SUBMIT X 60 of 60: 2022-01-16 02:45:16 - W - 1 scanf("%c",&choice); 12 3 if (age 21 && choice == 'S') 13 printf("cabernet"); 14 else 15 if (age > 21 && choice == 'T') 16 printf("chardonnay"); 17 else 18 if (age > 21 && choice == 'B'); 19 printf ("IPA"); 20 21 else 22 printf("invalid menu selection"); CODELAB ANALYSIS: COMPILER ERROR(S) Print Content Results Support More Hints: We think you might want to consider using: {} V COMPILER ERROR MESSAGES CTest.c: In function 'main': ': CTest.c:25:10: error: 'else' without a previous 'if' else 1 #include 2 int main() { 3 int age; 4 char choice; 5 6 scanf("%c",&choice); 7 8 if (age 21 && choice == 'S') 18 printf("cabernet"); 19 else 20 if (age > 21 && choice == 'T') 21 printf("chardonnay"); 22 else 23 if (age > 21 && choice == 'B'); > = B) 24 printf("IPA"); 25 26 else 27 printf("invalid menu selection"); 28 29 return 0; 30 )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!