As part of a project in psychology, Ben has been administering a MBTI personality test. Now he has all the responses, but the task of scoring and compiling results seems daunting. He is hoping you can write a program to help him accomplish this task.
The personality test* is a series of 70 questions for which the available responses are ‘A’ and ‘B’. Based upon the answers to the 70 questions, a personality profile is determined, categorizing the degree to which the responses place the person on four scales:
Extrovert vs. Introvert (E/I)
Sensation vs. iNtuition (S/N)
Thinking vs. Feeling (T/F)
Judging vs. Perceiving (J/P).
Each of the 70 questions relates to one of the four scales, with an ‘A’ response indicating the first of the corresponding pair (E, S, T, or J) and a ‘B’ indicating the second (I, N, F, or P). For instance, an ‘A’ response on the question:
At a party do you:
A. Interact with many, including strangers
B. Interact with a few, known to you
indicates an Extrovert rather than an Introvert; just the opposite for a ‘B’.
For this test, each question is designed to influence one of the four scales as follows:
questions 1, 8, 15, 22, 29 … are used to determine E/I,
questions 2, 9, 16, 23, 30 … and 3, 10, 17, 24, 31 … to determine S/N,
questions 4, 11, 18, 25, 32 … and 5, 12, 19, 26, 33 … to determine T/F, and
questions 6, 13, 20, 27, 34 … and 7, 14, 21, 28, 35 … to determine J/P.
Notice these come in sequences of “every 7th” question.
The goal of the test is to determine which end of each of the four scales a person leans, and to thus classify him/her based on those leanings (e.g., as ENFJ, INTJ, etc.). Since Ben would also like an indication of how strongly the test taker fell into each of the four, the program should print the percentage of ‘A’ responses for that scale.
Input for this program should come from a file responses.txt. The first line of the file will contain a single integer, n, indicating the number of test results to follow. Each of the following n lines will contain the first name of the test taker, a single blank, his/her last name, a single blank, then the 70 responses he/she gave on the test. Although the test instructions indicate that the results are most valid when all questions are answered, sometimes respondents leave questions blank. In that case, a dash appears at the corresponding place in the list of responses.
Output for the program should be written to the file types.txt. It should include a well-formatted report listing, for each test taker, his/her name, the percentage of ‘A’ responses in each scale, and the resulting personality type. A tie within a scale should result in a dash (‘-‘) for that part of the personality type.
For example, if the contents of responses.txt is
3
Mickey Mouse AABABBBBAAABBBABBBBAAAAABBABBAABB-BBAAABBABBABBBBABABBBABABBABBBAAA-BA
Minnie Mouse BAAABABABBAAABBBABABA-BBAAAABBABABBABBABABBBABABABBBABBBABAAABABABABB-
Donald Duck A-BBAAAB-BBAABBBABAABBBABABABAB-BABABABBBBABAAABABABBABABBBAAAABABBBBA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void personalityType (int, int, int,int);
int main()
{
ifstream infile("responses.txt");
for ( int i = 0; i < 3; i++)
{
cin >> infile ("responses.txt");
}
system("pause");
return 0;
}
void personalityType (int, int, int,int);
|