Write a program that reads by asking the user the name of the file. After opening it, read it into the structure of array. The input file is in the format: firstName  lastName age result (Contents of the input file) The Temp 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Edward Newman 61 3 1 2 2 2 3 5 3 5 3 5 1 3 1 4 3 5 2 5 3 5 1 3 1 5 1 5 3 1 1 3 1 3 1 3 3 5 2 1 2 3 5 1 1 3 3 5 3 1 5 The program reads the result into the structure called TheResult. The constants and the structure to be used is given below: const int EXTROVERSION = 0; const int AGREEABLENESS = 1; const int CONSCIENTIOUSNESS = 2; const int NEUROTICISM = 3; const int OPEN_TO_EXPERIENCE = 4; const int NUM_QUESTIONS = 50; const int NUM_RESULT = 5; const int MAX_RESULT = 5; struct TheResult {   string firstName;   string lastName;   int age;   int answers[NUM_QUESTIONS]; // result   double normalizedResult[NUM_RESULT];   }; The nam

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Write a program that reads by asking the user the name of the file. After opening it, read it into the structure of array. The input file is in the format: firstName  lastName age result (Contents of the input file) The Temp 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Edward Newman 61 3 1 2 2 2 3 5 3 5 3 5 1 3 1 4 3 5 2 5 3 5 1 3 1 5 1 5 3 1 1 3 1 3 1 3 3 5 2 1 2 3 5 1 1 3 3 5 3 1 5 The program reads the result into the structure called TheResult. The constants and the structure to be used is given below: const int EXTROVERSION = 0; const int AGREEABLENESS = 1; const int CONSCIENTIOUSNESS = 2; const int NEUROTICISM = 3; const int OPEN_TO_EXPERIENCE = 4; const int NUM_QUESTIONS = 50; const int NUM_RESULT = 5; const int MAX_RESULT = 5; struct TheResult {   string firstName;   string lastName;   int age;   int answers[NUM_QUESTIONS]; // result   double normalizedResult[NUM_RESULT];   }; The name of the input file is obtained from the user. The data is read into an array of structures. After reading the data from the input file into the array of TheResult structures, calculate each result’s normalized result scores using the formulas below where (n) is the numeric answer to question n. extroversion = 20+(1)–(6)+(11)-(16)+(21)-(26)+(31)-(36)+(41)-(46) • agreeableness = 14-(2)+(7)-(12)+(17)-(22)+(27)-(32)+(37)+(42)+(47) • conscientiousness = 14+(3)-(8)+(13)-(18)+(23)-(28)+(33)-(38)+(43)+(48) • neuroticism = 38-(4)+(9)-(14)+(19)-(24)-(29)-(34)-(39)-(44)-(49) • openness to experience = 8+(5)-(10)+(15)-(20)+(25)-(30)+(35)+(40)+(45)+(50) Calculate each result’s score then normalize it from a scale of 0 to 40 to a scale of 1 to 5. For example: normalizedResult[EXTROVERSION] = (extroversion + 10)/10; After scoring all results, sort the array of TheResult structures by last name, calculate the averages of each trait, and print the array and averages in a form of a table as shown in the image.
Last Name
ΝΟ
Newman
3.0 4.2
Temp
3.0 3.0
Average
0.5 3.6
First Name
Edward
The
Age E A C
61 3.6 4.7 4.3
0 3.0 3.0 3.0
3.3 3.8 3.6
Transcribed Image Text:Last Name ΝΟ Newman 3.0 4.2 Temp 3.0 3.0 Average 0.5 3.6 First Name Edward The Age E A C 61 3.6 4.7 4.3 0 3.0 3.0 3.0 3.3 3.8 3.6
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education