Personality Test

Personality Test Objectives: Practice file I/O, array, and modular design with static methods. Write a Java program to score examinees’ responses to a personality test. Assume that the test has 70 questions that determine a person’s personality in four dimensions. Each question has two answer choices, which we will refer to as the "A" and "B" answer. The person taking the test is allowed to leave a question blank, in which case the answer will be recorded with a dash ("-"). The test measures four independent dimensions of personality: 1. Extrovert versus Introvert (E vs I): what energizes you 2. Sensation versus iNtuition (S vs N): what you focus on 3. Thinking versus Feeling (T vs F): how you interpret what you focus on 4. Judging versus Perceiving (J vs P): how you approach life Examinees are categorized as being on one side or the other for each dimension. The corresponding letters are put together to form a personality type. For example, if you are an Extrovert, iNtuitive, Thinking, Perceiving person then you are referred to as an ENTP individual. The "A" answers correspond to E, S, T, and J. The "B" answers correspond to I, N, F, and P. For each dimension, we determine a percentage of "B" answers the user gave for that dimension between 0 and 100, to indicate whether the person is closer to the "A" or "B" side. To be more specific, if less than 50% of an examinee’s responses are "B" for a given personality dimension, the person’s type for that dimension should be the first of its two choices. If the examinee has more than 50% of "B" responses, the examinee’s type for that dimension is the second choice. If the numbers of "A" and "B" answers are the same for that dimension, or the number of skipped questions exceeds 1/5 of the total questions for that dimension, then the examinee will be assigned letter X, indicating indeterminate. Suppose that an examinee's answers are as follows. Dimension # of "A" answers # of "B" answers % of "B" answers Result Extrovert/Introvert 1 9 90% I Sensing/iNtuition 17 3 15% S Thinking/Feeling 10 10 50% X Judging/Perceiving 18 2 10% J We add up how many of each type of answer we got for each dimension. Then we compute the percentage of "B" answers for each dimension. Then we assign letters based on which side the person ends up on for each dimension. In the Extrovert/Introvert dimension, for example, the above examinee gave 9 "B" answers out of 10 total (90%), which means he or she is on the "B" side, which is "Introvert" or I. The overall percentages are (90, 15, 50, 10) which works out to a personality type of ISXJ. Test questions are organized into 10 groups of seven questions, with the following repeating pattern in each group: 1. The first question in each group is an Introvert/Extrovert question (questions 1, 8, 15, 22, etc). 2. The next two questions are for Sensing/iNtuition (questions 2 and 3, 9 and 10, 16 and 17, 23 and 24, etc). 3. The next two questions are for Thinking/Feeling (questions 4 and 5, 11 and 12, 18 and 19, 25 and 26, etc). 4. The next two questions are for Judging/Perceiving (questions 6 and 7, 13 and 14, 20 and 21, 27 and 28, etc). In other words, if we consider the I/E to be dimension 1, the S/N to be dimension 2, the T/F to be dimension 3, and the J/P to be dimension 4, the map of questions to their respective dimensions would look like this: 1223344122334412233441223344122334412233441223344122334412233441223344 BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA Your program will process a test data file. The file will contain line pairs, one per examinee. The first line has the examinee’s name, and the second has the examinee's 70 answers (all "A", "B" or "-"). The "A" and "B" in the file can be upper or lowercase. A dash represents a question that was skipped. For example, Betty BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA Ben aabaabbabbbaaaabaaaabaaaaababbbaabaaaabaabbbbabaaaabaabaaaaaabbaaaaabb Han BA-ABABBB-bbbaababaaaabbaaabbaaabbabABBAAABABBAAABABAAAABBABAAABBABAAB Your program begins by asking for the input file name. If the input file does not exist in the same folder where your java file is stored, prompt again until a valid file name is typed. Your program should print the scoring results to an output file. Each pair of lines from the input file is turned into a group of lines in the output file with the examinee’s name, count of As and Bs for each dimension, % Bs for each dimension (rounded to the nearest whole percent), and personality type. Suppose the input file contains test data for two examinees, Betty and Snoopy, then your output file should be in the format as follows. Betty: 1A-9B 17A-3B 18A-2B 18A-2B [ 90%, 15%, 10%, 10%] = ISTJ Snoopy: 7A-3B 11A-9B 14A-6B 6A-14B [ 30%, 45%, 30%, 70%] = ESTP User interface specifications:  Input o The program prompts users for the input file name. o You can create your own data file with text editor. A sample data file called sample.txt has been provided for your reference. Please download it from the course web site.  Output o A text file that is generated by your program for reporting your scoring results for each examinee in the input file. o Your output file name must be in the following format: report_by_yourfirstname.txt (e.g., report_by_steve.txt) o The output file called report_by_kai.txt for the input file sample.txt is also provided for your self-checking. Code specifications:  The header comment lines at the top of the file contain a brief description of the program. The description should be one or 2 lines long describing the purpose of the program.  Partition the task into smaller subtasks and implement each subtask with static method(s), i.e., function(s). Each static method must have comment lines describing its functionality, parameters, and the return, as applicable. o You should have at least three methods other than “main” that perform some nontrivial part of the problem.  Your “main” function is to aggregate the decomposed subtasks. You also have to include comment lines in your “main” function to describe the logic or flow of your solution to the whole problem. o Your “main” method should not directly perform file input/output.  You should use arrays to store the various data for each of the four dimensions of the personality test.  Use Javadoc’s comment formats for program and methods documentation.  For this assignment you are limited to language features in Chapters 1 through 7 of the textbook. Building Java 3rd edition  Use descriptive variable names and function/method names.  Define constants whenever appropriate.