12 Hailey 80 90 Paul 88 73 April 78 56 Sonya 80 71 John 56 68 Pam 70 72 Oliver 90 95 Eugene 67 79 Harry 81 65 Jessica 56 82 Eileen 98 77 Lily 77 72 } // Complete the class Enter the fileName : data.txt Data from file Hailey 80 90 85 Paul 88 73 80.5 April 78 56 67 75.5 Sonya 80 71 John 56 68 Pam 70 72 62 71 Oliver 90 95 92.5 Eugene 67 70 68.5 Harry 81 65 Jessica 56 82 Eileen 98 77 87.5 Lily 77 72 74.5 Sorted data 73 69 Oliver 90 95 92.5 Eileen 98 77 87.5 Hailey 80 90 85 Paul 88 73 80.5 Sonya 80 71 75.5 Lily 77 72 74.5 Harry 81 65 Pam 70 72 Jessica 56 82 Eugene 67 70 April 78 56 John 56 68 73 71 69 } 68.5 67 62 // Complete the class

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

Use C++

here is the

data.txt :

12
Hailey 80 90
Paul 88 73
April 78 56
Sonya 80 71
John 56 68
Pam 70 72
Oliver 90 95
Eugene 67 79
Harry 81 65
Jessica 56 82
Eileen 98 77
Lily 77 72
The image contains the contents of a file, `data.txt`, and its processing output, showing student names and their corresponding scores.

**Contents of `data.txt`:**
```
12
Hailey 80 90
Paul 88 73
April 78 56
Sonya 80 71
John 56 68
Pam 70 72
Oliver 90 95
Eugene 67 79
Harry 81 65
Jessica 56 82
Eileen 98 77
Lily 77 72
```

This section begins with a number "12", which likely indicates the number of records or entries. It is followed by the names of students along with two scores each.

**Output After Processing the File:**

1. **Data from file:**
   - Lists each student with their scores and computes an average of the two scores.
   - Example: "Hailey 80 90 85" indicates Hailey has scores 80 and 90 with an average of 85.0.

```
Hailey 80 90 85
Paul 88 73 80.5
April 78 56 67
Sonya 80 71 75.5
John 56 68 62
Pam 70 72 71
Oliver 90 95 92.5
Eugene 67 70 68.5
Harry 81 65 73
Jessica 56 82 69
Eileen 98 77 87.5
Lily 77 72 74.5
```

2. **Sorted data:**
   - The data is sorted by the average score in descending order.
   - Example: "Oliver 90 95 92.5" appears first with the highest average of 92.5.

```
Oliver 90 95 92.5
Eileen 98 77 87.5
Hailey 80 90 85
Paul 88 73 80.5
Sonya 80 71 75.5
Lily 77 72 74.5
Harry 81 65 73
Pam 70 72 71
Jessica 56 82 69
Eugene 67 70 68.5
April 78 56 67
John 56 68 62
``
Transcribed Image Text:The image contains the contents of a file, `data.txt`, and its processing output, showing student names and their corresponding scores. **Contents of `data.txt`:** ``` 12 Hailey 80 90 Paul 88 73 April 78 56 Sonya 80 71 John 56 68 Pam 70 72 Oliver 90 95 Eugene 67 79 Harry 81 65 Jessica 56 82 Eileen 98 77 Lily 77 72 ``` This section begins with a number "12", which likely indicates the number of records or entries. It is followed by the names of students along with two scores each. **Output After Processing the File:** 1. **Data from file:** - Lists each student with their scores and computes an average of the two scores. - Example: "Hailey 80 90 85" indicates Hailey has scores 80 and 90 with an average of 85.0. ``` Hailey 80 90 85 Paul 88 73 80.5 April 78 56 67 Sonya 80 71 75.5 John 56 68 62 Pam 70 72 71 Oliver 90 95 92.5 Eugene 67 70 68.5 Harry 81 65 73 Jessica 56 82 69 Eileen 98 77 87.5 Lily 77 72 74.5 ``` 2. **Sorted data:** - The data is sorted by the average score in descending order. - Example: "Oliver 90 95 92.5" appears first with the highest average of 92.5. ``` Oliver 90 95 92.5 Eileen 98 77 87.5 Hailey 80 90 85 Paul 88 73 80.5 Sonya 80 71 75.5 Lily 77 72 74.5 Harry 81 65 73 Pam 70 72 71 Jessica 56 82 69 Eugene 67 70 68.5 April 78 56 67 John 56 68 62 ``
In the file 'data.txt', there is information about students - name, C++ score, and Java score. The number 12 in the first line indicates the number of students.

(1) Create a dynamic array and store name, C++, and Java score.

Visual representation of the data structure:
```
| name      | name      | ...... | name      |
| score     | score     |        | score     |
| information | information |    | information |
```

(2) After storing the name, C++ score, and Java score, calculate the average and store it in the array.

(3) Complete the two classes and write the main function to print out the following result:

```cpp
class Score
{
private:
    int cpp;
    int java;
    double average;
public:
    // Complete the class
}

class Student
{
private:
    string name;
    Score* score;
public:
    // Complete the class
}
```

Contents of the file 'data.txt':
```
12
Hailey 80 90
Paul 88 73
April 78 56
Sonya 80 71
John 56 68
Pam 70 72
Oliver 90 95
Eugene 67 79
Harry 81 65
Jessica 56 82
Eileen 98 77
Lily 77 72
```

Expected program output:
```
Enter the fileName: data.txt

Data from file
---------------------------
Hailey 80 90 85
Paul 88 73 80.5
April 78 56 67
Sonya 80 71 75.5
John 56 68 62
Pam 70 72 71
Oliver 90 95 92.5
Eugene 67 79 73
Harry 81 65 73
Jessica 56 82 69
Eileen 98 77 87.5
Lily 77 72 74.5
```
Transcribed Image Text:In the file 'data.txt', there is information about students - name, C++ score, and Java score. The number 12 in the first line indicates the number of students. (1) Create a dynamic array and store name, C++, and Java score. Visual representation of the data structure: ``` | name | name | ...... | name | | score | score | | score | | information | information | | information | ``` (2) After storing the name, C++ score, and Java score, calculate the average and store it in the array. (3) Complete the two classes and write the main function to print out the following result: ```cpp class Score { private: int cpp; int java; double average; public: // Complete the class } class Student { private: string name; Score* score; public: // Complete the class } ``` Contents of the file 'data.txt': ``` 12 Hailey 80 90 Paul 88 73 April 78 56 Sonya 80 71 John 56 68 Pam 70 72 Oliver 90 95 Eugene 67 79 Harry 81 65 Jessica 56 82 Eileen 98 77 Lily 77 72 ``` Expected program output: ``` Enter the fileName: data.txt Data from file --------------------------- Hailey 80 90 85 Paul 88 73 80.5 April 78 56 67 Sonya 80 71 75.5 John 56 68 62 Pam 70 72 71 Oliver 90 95 92.5 Eugene 67 79 73 Harry 81 65 73 Jessica 56 82 69 Eileen 98 77 87.5 Lily 77 72 74.5 ```
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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