#include <iostream.h>

/* This program demonstrates the use of characters in menus. It inputs
   a number, and either doubles it, triples it, or quadruples it based
   on the choice ented be the user.
*/

main() {

  int number,  /* number to double, triple, or quadruple */
      result;  /* result of doubling, etc. */
  
  char option; /* Menu option selected by user */

  /* Tell user what program does, and prompt user for a number */

  cout << "This program either doubles, triples, or quadruples a number.\n"
       << "Enter a number: ";

  cin >> number;

  /* Print menu and prompt user for a character option */

  cout << "D)ouble number\nT)riple number\nQ)uadruple number\n"
       << "Choose one of the above by entering D, T, or Q: ";

  cin >> option;

  /* The switch statement is based on the character ented by the user.
     Note that we are comparing option with character constants in single
     quotes. Note also that we list both the capital and lower case 
     letters for user friendliness. */

  switch(option) {

    case 'D': case 'd':       /* The user entered D or d */
      result = 2 * number;    /* so double the number */
      break;

    case 'T': case 't':       /* The user entered T or t */
      result = 3 * number;    /* so triple the number */
      break;

    case 'Q': case 'q':       /* The user entered Q or q */
      result = 4 * number;    /* so quadruple the number */
      break;

    default:            /* The user entered none of the above */
      cout << "That is not an option!\n";
      exit(0);
    }

  cout << "The result is " << result << "\n";

  }

