The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 5 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
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.
This is what I have so far, I keep getting that it is incorrect...
scanf('%c', &choice);
char S, T, B;
if (age <22)
{Â Â
  if (choice == S)
  {
  printf("vegetable juice");
  }
  else if (choice == T)
  {
  printf("cranberry juice");
  }
  else if (choice == B)
  {
     printf("soda");
  }
}
else
{
  if (choice == S)
  {
  printf("cabernet");
  }
  else if (choice == T)
  {
  printf("chardonnay");
  }
  else if (choice == B)
  {
     printf("IPA");
  }
}
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll