Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 5 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 28 Aug 2017 My Price 9.00

int variable age

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");
   }
}

Answers

(5)
Status NEW Posted 28 Aug 2017 01:08 PM My Price 9.00

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

Not Rated(0)