Prog2: MindReader
Prof. Reed, CS 141, Fall 2012
Due 9/21 before class at 12:00 noon
Description
Write a program in C (not C++) to play a mind-reader game sometimes called "Russian Magic Square". Your interface will be text-driven using numbers and letters of the alphabet and will not use graphics.
Running your program will look something like what is shown below, where user input is shown in bold:
Author: Dale Reed Program 2: Mind Reader TA: Karen Walker, Wed 7am Sept 12, 2012 99:h 98:K 97:b 96:I 95:h 94:z 93:U 92:A 91:C 90:d 89:G 88:h 87:W 86:t 85:C 84:v 83:K 82:h 81:h 80:d 79:O 78:p 77:f 76:x 75:h 74:W 73:Y 72:h 71:W 70:x 69:x 68:l 67:S 66:v 65:t 64:n 63:h 62:M 61:r 60:K 59:b 58:f 57:W 56:n 55:b 54:h 53:h 52:x 51:z 50:x 49:x 48:r 47:U 46:f 45:h 44:f 43:h 42:S 41:S 40:E 39:j 38:x 37:p 36:h 35:G 34:W 33:Q 32:z 31:O 30:z 29:t 28:j 27:h 26:M 25:A 24:A 23:t 22:j 21:n 20:v 19:t 18:h 17:S 16:t 15:r 14:l 13:S 12:O 11:M 10:h 9:h 8:v 7:Y 6:b 5:I 4:t 3:v 2:h 1:A 0:h 1. Choose any two-digit number in the table above (e.g. 73). 2. Subtract its two digits from itself (e.g. 73 - 7 - 3 = 63) 3. Find this new number (e.g. 63) and remember the letter next to it. 4. Now press 'r' and I'll read your mind... r I sense you are thinking of: h Enter 'r' to repeat or 'x' to exit: r 99:z 98:n 97:d 96:O 95:h 94:K 93:x 92:G 91:C 90:d 89:E 88:p 87:f 86:W 85:Y 84:z 83:A 82:v 81:z 80:l 79:z 78:Q 77:E 76:S 75:W 74:l 73:U 72:z 71:z 70:K 69:K 68:x 67:I 66:W 65:r 64:G 63:z 62:l 61:d 60:I 59:n 58:x 57:W 56:O 55:Y 54:z 53:G 52:W 51:v 50:j 49:O 48:n 47:I 46:U 45:z 44:W 43:Q 42:I 41:S 40:Y 39:n 38:b 37:d 36:z 35:z 34:W 33:r 32:E 31:r 30:O 29:E 28:n 27:z 26:W 25:C 24:S 23:C 22:Q 21:f 20:z 19:z 18:z 17:G 16:C 15:j 14:t 13:n 12:M 11:G 10:C 9:z 8:Y 7:p 6:n 5:z 4:n 3:Q 2:d 1:K 0:z 1. Choose any two-digit number in the table above (e.g. 73). 2. Subtract its two digits from itself (e.g. 73 - 7 - 3 = 63) 3. Find this new number (e.g. 63) and remember the letter next to it. 4. Now press 'r' and I'll read your mind... r I sense you are thinking of: z Enter 'r' to repeat or 'x' to exit:
You need to know the following concepts in order to write this program:
How to use some C IDE (e.g. DevC++, Visual C++), simple input and output, using variables, simple if statements, a while loop, generating a random number, turning in program to Blackboard
Notes:
Make sure you have read chapters 1 & 2 before starting this assignment. You will also need sections of chapter 3.
What you can/can't use:
All your code must be inside of main()
You may not use arrays
Make sure you read the syllabus regarding the grading criteria. Particularly on the first program, students tend to lose points for not documenting adequately and for not choosing meaningful variable names.
See this sample program which gives you a good starting point, as well as illustrate various concepts you need for this program.
I suggest you work on the program one piece at a time. Don't try to write the whole thing, type the whole thing in, then debug the whole thing. Write just a bit, compile and test, and continue like that.
Note that in the example shown above the program repeats only once. Your program should handle repeating as many times as the user would like.
Note that you must give both upper and lower case letters in your table. One way to do this is to check your random number. If it is even, generate an upper-case letter. If it is odd, generate a lower-case letter.
Remember to include your TA's NAME and your LAB DAY in the documentation header of your programs AS WELL AS in the output that appears on the screen.
Do not be deceived. This is considered to be an easy program, compared to what is to come in the course.
Extra Credit: have more than one "formula" that you use for figuring out what the user's guess must be. Make sure that it always works, and have the program randomly change which version is used.
Turnin your program electronically into Blackboard. Multiple submissions are accepted, but only the most recent one will be graded.