Program 6

Some capital letters display symmetry of various types. We can classify the letters as follows:
Horizontal symmetry: B, C, D, E, H, I, K, O, X (top and bottom are the same)
Vertical symmetry: A, H, I, M, O, T, U, V, W, X, Y (left and right halves are the same)
Rotational symmetry: H, I, N, O, S, Z, X (same right-side up or upside down)
None: F, G, J, L, P, Q, R

We can also classify words as having a type of symmetry. For example, TO is vertically symmetrical because both letters in the word are vertically symmetrical. Similarly, DO is horizontally symmetrical because both 'D' and 'O' are horizontally symmetrical. The word OHIO is symmetrical in all three senses, because each letter displays horizontal, vertical, and rotational symmetry.

You are to write a program that will determine which type(s) of symmetry a word displays, if any. The words will come from an input file. Your program must read the word one character at a time and determine what kind(s) of symmetry it possesses. If all the characters in a particular word display one or more types of symmetry, then the program must display a message stating the symmetries found.

To do this most effectively, you can take advantage of the power of sets. A set, you will recall from mathematics, is an abstract concept that gathers together elements that share some common property or properties. For example, we could define a set of all positive integers that are evenly divisible by two, or a set of all people with red hair and no freckles. The operations defined for sets allow us to combine them in particular ways. For example, the intersection of two sets gives a set with only the elements common to both of the intersected sets. The union of two sets yields a set with all of the elements contained in both the operands. You can refresh your knowledge of sets by reviewing the information on the sets library functions. To understand how sets can help you with this problem, consider the example word TO. The set of symmetries of the letter T is a singleton set: {VERTICAL}. The set of symmetries of the letter O has three elements: {VERTICAL HORIZONTAL ROTATIONAL}. The intersection of these sets, {VERTICAL}, gives the symmetry of the word itself.

Input

Input will come from the file data6.txt. It will consist of words, one per line. Only capital letters will appear.

Output

Output will go to the file results6.txt. Each line of this file will contain the original word, followed by a list of the symmetries for the word.

Example

data7.txt

TWO
SHADE
DID
OHIO
MYTH
HIDE
SHIN

results7.txt

TWO
SHADE
DID
OHIO
MYTH
HIDE
SHIN
Vertical
None
Horizontal
Horizontal Vertical Rotational
Vertical
Horizontal
Rotational

Specific Requirements

  1. Your program must use sets
  2. Your program must use at least one switch statement
  3. Your program must use an enumerated type definition
  4. Your program must use functions appropriately

Deliverables

Be sure to follow the instructions on the General Information and Coding Standards pages.

  1. Your C source code. Name your program prog6.c 
  2. A text-only top-down design. Name this file prog6.tdd 
  3. A text-only "Boasts and Confessions" form. Name this file prog6.bc