Classwork 4 - UMBC-CMSC104/General GitHub Wiki

Name this program age.c.

For this program, you're to prompt the user for their age.

Welcome to classwork 4!
How old are you?

If the user enters an age less than 0, output:

Liar!

If the user enters an age between 0 and 18 (not including 18), output:

So young!

If the user enters an age between 18 and 22 inclusive, ask the user if they're in college:

Are you in college?

If the user enters y, output:

Good for you!

Otherwise, output:

You should really consider going.

For any other age (22 and older), I'll leave the choice of output to you. There must be some output to distinguish that a user is older than 22, however.

To submit this classwork, type:

submit cs104_wilson cw04 age.c

Notes

  • Use [https://github.com/UMBC-CMSC104/General/blob/master/cw03/menu.c](classwork 3) as a reference.
  • You'll need to use the && operator as well as > and <.
  • You will need to use a nested if for prompting the user if they went to college. You will be reading in a character here. After reading in the character, you may need to use getc(stdin).
  • You will need to have multiple else ifs, as well as an else.

That would look like this:

if(...)
{
    some code
}
else if(...)
{
    some code
}
else if(...)
{
    some code
}
else
{
    some code
}