Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program (PersonalityTest.java) to score users responses to the classic M

ID: 3656754 • Letter: W

Question

Write a program (PersonalityTest.java) to score users responses to the classic Myers-Briggs personality test. Assume that the test has 70 questions that determine a persons personality in four dimensions. Each question has two answer choices that well call the A and B answers. 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, ... 64) tells whether the person is Extrovert or Introvert.

The next two questions (questions 2 and 3, 9 and 10, 16 and 17, ..., 65 and 66) test whether the person is guided by his/her Sense or iNtuition.

The next two questions (questions 4 and 5, 11 and 12, 18 and 19, ..., 67 and 68) test whether the person focuses on Thinking or Feeling.

The final two questions in each group (questions 6 and 7, 13 and 14, 20 and 21, ... 69 and 70) test whether the person prefers to Judge or be guided by Perception.

In other words, if we consider extrovert/introvert (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:

12233441223344122334412233441223344122334412233441223344122334412 23344 BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABA AAAAA

The following is a sample input file of names and responses:

Betty Boop BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABA AAAAA
Bugs Bunny aabaabbabbbaaaabaaaabaaaaababbbaabaaaabaabbbbabaaaabaabaaaaaabbaa aaabb
Han Solo
BA-ABABBB- bbbaababaaaabbaaabbaaabbabABBAAABABBAAABABAAAABBABAAABBABAAB

The input file contains a name followed by his/her responses to the test. The answer to a question is case insensitive, and can be A, B, or where a dash represents that the person skipped that question. If less than 50% of a persons responses are B for a given personality dimension, the persons type for that dimension should be the first of its two choices. If the person answers B more than 50%, the persons type for that dimension is the second choice. If the person has the same number of As and Bs for a dimension, give them an X (as with Han Solo).

Ask the user to enter the input filename and check if the file exists. If yes, process the file. Otherwise, ask the user again to enter the input filename until a correct name is entered. You may assume that the input file contains no errors and that nobody has skipped all questions for a dimension.

Given the above input file, the resulting output would be:

Betty Boop
1A-9B 17A-3B 18A-2B 18A-2B [90%, 15%, 10%, 10%] = ISTJ

Bugs Bunny
8A-2B 11A-9B 17A-3B 9A-11B [20%, 45%, 15%, 55%] = ESTP

Han Solo

2A-8B 9A-9B 11A-9B 15A-5B [80%, 50%, 45%, 25%] = IXTJ

Explanation / Answer

import java.util.*; import java.io.*; public class MyersBriggs{ public static final int Define = 0; public static final int SecondSet1 = 1; //to avoid magic numbers public static final int SecondSet2 = 2; public static final int ThirdSet1 = 3; public static final int ThirdSet2 = 4; public static final int FourthSet = 5; public static final int Test = 6; //check what category question falls into public static void main (String[] args){ Scanner console = new Scanner (System.in); File f = getFile( console ); processFile(f); } public static File getFile( Scanner keyboard ) { System.out.print( "Enter name of file to be processed: " ); String fileName = keyboard.nextLine(); File f = new File( fileName ); System.out.println(); return f; } public static void processFile(File f)throws FileNotFoundException{ Scanner input = new Scanner (f); while (input.hasNextLine()){ int SnA = 0; int SnB = 0; String text = input.nextLine(); while (( text.charAt(0) == "S")||(text.charAt(0) == "L")||(text.charAt(0) == "P")){ text.nextLine(); } int numberOfChar = text.length(); int intro = 0; //subject is introverted int extro = 0; //subject is extroverted int sense = 0; //guided by senses int intui = 0; //guided by intuition int think = 0; //focus on thinking int feeli = 0; //focus on feeling int judge = 0; //prefer to judge int perce = 0; //guided by perception int i=0; for (i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote