Question
JAVA Programming Assignment: Personality Test Problem Statement: This assignment will acquaint you with working with arrays to keep a tally of counts and passing arrays
JAVA Programming Assignment: Personality Test Problem Statement:
This assignment will acquaint you with working with arrays to keep a tally of counts and passing arrays as parameters and as return type. You will write a program that scores users responses to the classic MyersBriggs personality test.
Assume that the test has 70 questions which determine a persons personality in four dimensions. Each question has two answer choices which we will call A and B. Questions are organized into 10 groups of seven questions, with the following repeating pattern in each group:
-
The first question in each group (questions 1, 8, 15, 22, etc.) tells whether the person is extroverted or introverted (E/I).
-
The next two questions (questions 2 and 3, 9 and 10, 16 and 17, 23 and 24, etc.) test whether the person is guided by his or her senses or intuition (S/N).
-
The next two questions (questions 4 and 5, 11 and 12, 18 and 19, 25 and 26, etc.) test whether the person focuses on thinking or feeling (T/F).
-
The final two questions in each group (questions 6 and 7, 13 and 14, 20 and 21, 27 and 28, etc.) test whether the person prefers to judge or be guided by perception (J/P).
In other words, if we consider extraversion/introversion (E/I) to be dimension 1, sensing/intuition (S/N) to be dimension 2, thinking/feeling (T/F) to be dimension 3, and judging/perception (J/P) to be dimension 4, the map of questions to their respective dimensions would look like this:
1223344122334412233441223344122334412233441223344122334412233441223344
You can see that the same pattern of 7 questions repeats 10 times. Following is an example of a set of answers to these questions:
The following is a partial sample input file of names and responses:
1223344122334412233441223344122334412233441223344122334412233441223344 BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA
Betty Boop
BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA
Snoopy
AABBAABBBBBABABAAAAABABBAABBAAAABBBAAABAABAABABAAAABAABBBBAAABBAABABBB
Clearly, the number of As or Bs determine the persons personality type on that dimension. For example, if a person gives B as the answer 5 out of 7 times (i.e. more than 50% times) for dimension 1 (introverted/extroverted/ introverted) he/she is introvertedextroverted.
Your program should output each persons name, the number of A and B responses for each dimension, the percentage of Bs in each dimension, and the overall personality type. The following should be your programs output for the preceding input data:
Betty Boop:
1A9B 17A3B 18A2B 18A2B
[90%, 15%, 10%, 10%] = ISTJ
Snoopy:
7A3B 11A9B 14A6B 6A14B
[30%, 45%, 30%, 70%] = ESTP
Specifically, write a complete class called PersonalityTest that has the following:
-
(5 points) main method:
-
Prompts the user for the name of the input file (of the form *.txt a text file
located in the same folder as your program)
-
Creates a Scanner object to read that file.
-
Creates a PrintStream object to write the translated text to an output file. Name
the output file by adding out to the input file name. For example, if the input
file is original.txt, output file should be original-out.txt.
-
Calls the method processPerson repeatedly passing the Scanner and the
PrintStream objects until there is no data left in the file. (Assume that the input file will have the exact format shown above for each person: name on one line, followed by a sequence of 70 As and Bs on the next line).
-
-
(8 points) processPerson method that accepts two objects as parameters: Scanner to read the input file and PrintStream to write the output file. This method will read data for one person at a time from the Scanner, process it using below-mentioned helper methods and print the report for that person to the PrintStream object as shown above.
-
(5 points) computeTally method that accepts a String as a parameter representing the line containing 70 responses (As and Bs) and returns the tally array of counts of Bs for each of the four dimensions. For example, for the first person in the sample above (Betty Boop), this method will return the array [9,3,2,2].
-
(3 points) computePercentage method that accepts the output of computeTally method (array of counts of responses for each dimension) and returns an array of doubles with percentage values for the four dimensions, taking into account maximum number of responses possible for each dimension. Using the same example above, for the first person (Betty Boop), this method will return the array [0.9, 0.15, 0.1, 0.1].
-
(5 points) Design and program structure: Use for-loop traversal of arrays or strings wherever possible. Use Fencepost algorithm wherever needed (for example you will
need it to get the exact output format shown above). Make sure you use class constants for various quantities instead of hard-coded values. Here is a possible set of class constants:
public static final String[] OPTIONS = {"EI", "SN", "TF", "JP"}; public static final int[] MAX_VALUES = {10,20,20,20}; public static final int DIMENSIONS = 4; public static final int QUESTIONS = 7;
public static final int GROUPS = 10; Notice that an array can be declared as a class constant as well.
6. (4 points) - Include appropriate program documentation and formatting including: Your first and last name, the date of submission, code comments necessary to explain the operation of your program, and proper indentation of the code, etc.
Note:
-
Read the description above closely to understand what is expected of your program.
-
Make sure your program can find the input file correctly. Different IDEs may behave differently in this regard. Note the user input will include the file extension (.txt) as well.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started