Question
personality.cpp #include #include #include using namespace std; #define FILE_ERROR -1 #define SUCCESS 0 #define FAILURE -10 const int SIZE = 4; const string LETTERS =
personality.cpp
#include
#define FILE_ERROR -1 #define SUCCESS 0 #define FAILURE -10 const int SIZE = 4; const string LETTERS = "ESTJINFP"; const char X = 'X'; /* * A structure that stores the name of each person, their answers * their answer counts, their percentages for the four * categories and the final result (ISTJ) */ struct Personality { string name; string answers; int counts[SIZE * 2]; int percentages[SIZE]; char result[SIZE + 1]; // Adding one to be able to make it a C-String. };
// Opens the file with the name, reads the first entry into size, // creates a dynamic array of personality variables // and populates their corresponding name and answers. // Returns personalities if successful or NULL on failure. Personality * processfile(string, int& size);
// Iterates through the personality array and tallies // up the counts for the answers. void processcounts(Personality *, int size);
// Iterates through the personality array and calculates // the percentages based on the counts. void calculatepercentages(Personality *, int size);
// Determines the personality and sets the result into the // array for each person. void determinepersonality(Personality *, int size);
// Writes to the filename passed all the relevant data. void writetofile(string, const Personality *, int size);
int main() { // Make it all work here return 0; }
personality_functions.txt
9 Betty Boop BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA Snoopy AABBAABBBBBABABAAAAABABBAABBAAAABBBAAABAABAABABAAAABAABBBBAAABBAABABBB Bugs Bunny aabaabbabbbaaaabaaaabaaaaababbbaabaaaabaabbbbabaaaabaabaaaaaabbaaaaabb Daffy Duck BAAAAA-BAAAABABAAAAAABA-AAAABABAAAABAABAA-BAAABAABAAAAAABA-BAAABA-BAAA The frumious bandersnatch -BBaBAA-BBbBBABBBBA-BaBBBBBbbBBABBBBBBABB-BBBaBBABBBBBBB-BABBBBBBBBBBB Minnie Mouse BABA-AABABBBAABAABA-ABABAAAB-ABAAAAAA-AAAABAAABAAABAAAAAB-ABBAAAAAAAAA Luke Skywalker bbbaaabbbbaaba-BAAAABBABBAAABBAABAAB-AAAAABBBABAABABA-ABBBABBABAA-AAAA Han Solo BA-ABABBB-bbbaababaaaabbaaabbaaabbabABBAAABABBAAABABAAAABBABAAABBABAAB Princess Leia BABBAAABBBBAAABBA-AAAABABBABBABBAAABAABAAABBBA-AABAABAAAABAAAAABABBBAA
This assignment tests your understanding of concepts dealing with functions and pointers We will also use some advanced file operations that are available in C++. The prototypes have already been provided to you and you cannot change them. You must write the code and call the functions in main to finish the program To begin, download personality functions.cpp file along with the input txt file personality functions.txt and follow the directions in the file to define the functions. The program processes an input file of data for a personality test known as the Keirsey Temperament Sorter. The Keirsey personality test involves answering 70 questions each of which have two answers. We will refer to them as the "A" answer and the "B" answer. People taking the test are allowed to leave a question blank, in which case their answer will be recorded with a dash The input file will contain a series of line pairs, one per person. The first line will have the person's name (possibly including spaces) and the second line will have a series of 70 letters all in a row (all either "A", "B" or Your job is to compute the scores and overall result for each person and to report this information to an output file The Keirsey test measures four independent dimensions of personality Extrovert versus Introvert (E vs I): what energizes you Sensation versus iNtuition (S vs N): what you focus on Thinking versus Feeling (T vs F): how you interpret what you focus on Individuals are categorized as being on one side or the other of each of these dimensions The corresponding letters are put together to form a personality type. For example, if you are an extravert, intuitive, thinking, perceiving person then you are referred to as an ENTP. Usually the letter used is the first letter of the corresponding word, but notice that because the letter "I" is used for "Introvert", the letter "N" is used for "iNtuition. Remember that the Keirsey test involves 70 questions answered either A or B. The A answers correspond to extravert, sensation, thinking and judging (the left-hand answers in the list above). The B answers correspond to introvert, intuition, feeling and perceiving (the right-hand answers in the list above) For each of these dimensions, we determine a This assignment tests your understanding of concepts dealing with functions and pointers We will also use some advanced file operations that are available in C++. The prototypes have already been provided to you and you cannot change them. You must write the code and call the functions in main to finish the program To begin, download personality functions.cpp file along with the input txt file personality functions.txt and follow the directions in the file to define the functions. The program processes an input file of data for a personality test known as the Keirsey Temperament Sorter. The Keirsey personality test involves answering 70 questions each of which have two answers. We will refer to them as the "A" answer and the "B" answer. People taking the test are allowed to leave a question blank, in which case their answer will be recorded with a dash The input file will contain a series of line pairs, one per person. The first line will have the person's name (possibly including spaces) and the second line will have a series of 70 letters all in a row (all either "A", "B" or Your job is to compute the scores and overall result for each person and to report this information to an output file The Keirsey test measures four independent dimensions of personality Extrovert versus Introvert (E vs I): what energizes you Sensation versus iNtuition (S vs N): what you focus on Thinking versus Feeling (T vs F): how you interpret what you focus on Individuals are categorized as being on one side or the other of each of these dimensions The corresponding letters are put together to form a personality type. For example, if you are an extravert, intuitive, thinking, perceiving person then you are referred to as an ENTP. Usually the letter used is the first letter of the corresponding word, but notice that because the letter "I" is used for "Introvert", the letter "N" is used for "iNtuition. Remember that the Keirsey test involves 70 questions answered either A or B. The A answers correspond to extravert, sensation, thinking and judging (the left-hand answers in the list above). The B answers correspond to introvert, intuition, feeling and perceiving (the right-hand answers in the list above) For each of these dimensions, we determine aStep 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