The mapping for the capital letter is as follows. Since we have 26 letters in our alphabet and we have 2 rows of 13 columns, letters will go from A through M on the first row, and N through Z on the second row. If the user enters "M", since M is the 13th character it will go on row 1, column 13. If the user enters "N", since N is the 14th character it will go on row 2, column 1. "Z" will go in row 2, column 13 since it is the 26th character. Check the sample run for some examples.
Notes and Hints:
| 1) | You must use a sentinel controlled while (or do while) loop in your program to control when to quit or continue; the value to test for in your condition is EOF |
| 2) | You must use getchar() to gather the character from the user.
Just after you get the character from the user, you must use the following
line of code to clean up the input buffer so it's ready for the next
character:
fflush ( stdin ); |
| 3) | You must use field width and precision for integers to get the leading zeroes on the header row (see sample run) and field width to properly align the character in the grid. Use a space and two underscores to represent a grid location without a letter. |
| 4) | The starting ASCII code value for 'A' is 65, and the values from continuously from there to 'Z' which is 90. To make the problem easier, you should find a simple calculation that makes that range of 65 to 90 into 1 to 26. |
| 5) | You are NOT to write an if/else if clause for each specific letter! Once you determine you have a valid capital letter, you are to calculate the row number and column number using the int value for the character. |
SAMPLE OUTPUT
SAMPLE RUN # 1 (Blue text is displayed by the computer,and the red represents the user's input):
Please enter a capital letter to map, CTRL-Z to quit:
A
01 02 03 04 05 06 07 08 09 10 11 12
13
A -- -- -- -- -- -- -- -- --
-- -- --
-- -- -- -- -- -- -- --
-- -- -- -- --
Please enter a capital letter to map, CTRL-Z to quit:
Z
01 02 03 04 05 06 07 08 09 10 11 12
13
-- -- -- -- -- -- -- -- -- --
-- -- --
-- -- -- -- -- -- -- --
-- -- -- -- Z
Please enter a capital letter to map, CTRL-Z to quit:
M
01 02 03 04 05 06 07 08 09 10 11 12
13
-- -- -- -- -- -- -- -- -- --
-- -- M
-- -- -- -- -- -- --
-- -- -- -- -- --
Please enter a capital letter to map, CTRL-Z to quit:
N
01 02 03 04 05 06 07 08 09 10 11 12
13
-- -- -- -- -- -- -- -- -- --
-- -- --
N -- -- -- -- -- -- --
-- -- -- -- --
Please enter a capital letter to map, CTRL-Z to quit:
a
a is not a valid capital
letter.
Please enter a capital letter to map, CTRL-Z to quit:
B
01 02 03 04 05 06 07 08 09 10 11 12
13
-- B -- -- -- -- -- -- --
-- -- -- --
-- -- -- -- -- -- --
-- -- -- -- -- --
Please enter a capital letter to map, CTRL-Z to quit:
^Z
Press any key to continue
SUBMISSION INSTRUCTIONS
You must an email copy of your .c file only to the grader (please make sure it's sent as an attachment!)
Your email MUST have the following in the Subject line to ensure you are not penalized for non or late submission!
INTROC:YOUR LAST NAME:YOUR FIRST NAME:HW#4
If it's late or you are allowed to resubmit, then follow the above with :LATE or :RESUBMIT as is applicable.
The grader's email is: aev208@nyu.edu. Please do NOT ask the grader questions. Questions should be directed to the list if general, or to me if more specific.
Good luck!