fork download
  1. //as a case statement
  2. #include <stdio.h>
  3. // John Gautreaux
  4. // john.gautreaux@g.austincc.edu
  5. // Graded Assignment 50%
  6. // http://w...content-available-to-author-only...t.com/moodle/mod/assignment/view.php?id=3546
  7.  
  8. int main () {
  9. // Variables
  10.  
  11. char name[150];
  12. int age;
  13. int age_check;
  14.  
  15. //Main Code
  16. printf("Can I see some ID?\n");
  17. printf("What’s your name and age please?\n");
  18. scanf("%s %d", name, &age );
  19.  
  20. switch(age_check){
  21. case 'under-20' :
  22. if (age <= 20) { // ********* check their ID to see if they are 20 or younger
  23. printf("Hey %s\t\n", name);
  24. printf("%d years old is too young get into a bar.\n", age);
  25. }
  26. break;
  27.  
  28. case '20-60' :
  29. if (age>20 && age<=60) { // ********* See if they are older than 20, but are 60 or younger
  30. printf("Sorry about that %s\n", name);
  31. printf("You don't look %d years old.\t\n", age);
  32. printf("You're an adult now it seems.\n");
  33. }
  34. break;
  35.  
  36. case '61 and over' :
  37. if (age > 60) {// ********* See if they are older than 60
  38. printf("%s, Can i help you cross the street?\n", name);
  39. printf("Looks like you are getting up there in age.\n");
  40. printf("I can't believe you are\t%d years old.\n",age);
  41. }
  42. break;
  43.  
  44. default : //********** No ID
  45. printf("Did you lose your ID?\n");
  46. printf("I can't let you in if you can't tell me your name and age\n");
  47. }
  48. return 0;
  49. }
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Can I see some ID?
What’s your name and age please?
Did you lose your ID?
I can't let you in if you can't tell me your name and age