fork download
  1. /********************************************************************
  2.  * Name: Elaine Torrez
  3.  * Lab 5 - enum Roster
  4.  * Description: Displays a student's birthday using an enum and switch.
  5.  ********************************************************************/
  6.  
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. // Global enum
  11. enum Roster { TOM = 1, SHARON, BILL, TERESA, JOHN };
  12.  
  13. int main()
  14. {
  15. int person;
  16.  
  17. cout << "This program will give you a student's birthday.\n\n";
  18.  
  19. cout << "1.) = Tom\n";
  20. cout << "2.) = Sharon\n";
  21. cout << "3.) = Bill\n";
  22. cout << "4.) = Teresa\n";
  23. cout << "5.) = John\n\n";
  24.  
  25. cout << "Whose birthday do you want to know? ";
  26. cin >> person;
  27.  
  28. switch (person)
  29. {
  30. case TOM:
  31. cout << "\nTom's birthday is January 3.\n";
  32. break;
  33.  
  34. case SHARON:
  35. cout << "\nSharon's birthday is April 22.\n";
  36. break;
  37.  
  38. case BILL:
  39. cout << "\nBill's birthday is May 19.\n";
  40. break;
  41.  
  42. case TERESA:
  43. cout << "\nTeresa's birthday is July 2.\n";
  44. break;
  45.  
  46. case JOHN:
  47. cout << "\nJohn's birthday is June 17.\n";
  48. break;
  49.  
  50. default:
  51. cout << "\nInvalid selection\n";
  52. }
  53.  
  54. cout << "\nPress any key to continue . . . ";
  55. cin.get();
  56. cin.get();
  57.  
  58. return 0;
  59. }
Success #stdin #stdout 0.01s 5324KB
stdin
3
stdout
This program will give you a student's birthday.

1.) = Tom
2.) = Sharon
3.) = Bill
4.) = Teresa
5.) = John

Whose birthday do you want to know? 
Bill's birthday is May 19.

Press any key to continue . . .