C++ Program For this program you’ll write a simple class and use it in a vector. Begin by writing a Student class. The public section has the following methods: Student::Student() Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0. bool Student::ReadData(istream& in) Data input. The istream should already be open. Reads the following data, in this order: First name (a string, 1 word) Last name (also a string, also 1 word) 5 quiz scores (integers, range 0-20) 3 exam scores (integers, range 0-100) Assumes that all data is separated by whitespace. The method returns true if reading all data was successful, otherwise returns false. Does not need to validate or range-check data; if one of the quiz or exam scores is out of range, just keep going. bool Student::WriteData(ostream& out) const Output function. Writes data in the following format. Each student’s data is on one line. • First name (left justified, 20 characters) • Last name (left justified, 20 characters) • 5 quiz scores (each right justified in a field 4 characters wide) • 3 exam scores (each right justified in a field 5 characters wide) • new-line character ‘\n’ or use of endl in output function Note that this is a const method; it should not modify any of the object’s data. Returns true if the attempt to send the data to the stream was successful, false otherwise. string Student::GetFirstName() const; string Student::GetLastName() const; Accessor methods, also known as ‘getters.’ Returns data from inside the function. float Student::CourseAverage() const Returns the student’s weighted average as a percentage (float in range 0-100). The quiz scores are averaged together (20-point scale) and are 35% of the course grade. The exams are averaged together and are 65% of the course grade. This does not modify any of the object’s data. bool Student::DisplayCourseAverage(ostream& out) const Prints the student’s course average to the provided output stream, rounded to 3 decimal places. Returns true if the attempt was successful, false otherwise. string Student::LetterGrade() const Returns a string with the student’s letter grade, using the same grading scale as this course. The class should assume that any input or output streams passed to public methods are already open. The main program is quite simple. You are provided a data file with data for some number of students. Read the data into a vector. (Hint: Declare one student. Read that student’s data, then add it to the vector. Repeat.) It should then print a roster, showing the name, course average to 3 decimal places, and letter grade for each student in the course. This list should be sorted by student name (sort by last name, break ties using first name; display in usual first-name last-name order). Results for the provided data file are shown. Your program will be tested against another data file with the same format. data file

Principles of Information Systems (MindTap Course List)
13th Edition
ISBN:9781305971776
Author:Ralph Stair, George Reynolds
Publisher:Ralph Stair, George Reynolds
Chapter10: Knowledge Management And Specialized Information Systems
Section: Chapter Questions
Problem 14SAT
icon
Related questions
Question

C++ Program

For this program you’ll write a simple class and use it in a vector.
Begin by writing a Student class. The public section has the following methods:

Student::Student()
Constructor. Initializes all data elements: name to empty string(s), numeric variables to 0.

bool Student::ReadData(istream& in)
Data input. The istream should already be open. Reads the following data, in this order:

  • First name (a string, 1 word)

  • Last name (also a string, also 1 word)

  • 5 quiz scores (integers, range 0-20)

  • 3 exam scores (integers, range 0-100)

    Assumes that all data is separated by whitespace. The method returns true if reading all data was successful, otherwise returns false. Does not need to validate or range-check data; if one of the quiz or exam scores is out of range, just keep going.

    bool Student::WriteData(ostream& out) const
    Output function. Writes data in the following format. Each student’s data is on one line.

    First name (left justified, 20 characters)
    • Last name (left justified, 20 characters)
    • 5 quiz scores (each right justified in a field 4 characters wide)

    • 3 exam scores (each right justified in a field 5 characters wide)

    • new-line character ‘\n’ or use of endl in output function

    Note that this is a const method; it should not modify any of the object’s data. Returns true if the attempt to send the data to the stream was successful, false otherwise.

    string Student::GetFirstName() const;
    string Student::GetLastName() const;
    Accessor methods, also known as ‘getters.’ Returns data from inside the function.

    float Student::CourseAverage() const
    Returns the student’s weighted average as a percentage (float in range 0-100). The quiz scores are averaged together (20-point scale) and are 35% of the course grade. The exams are averaged together and are 65% of the course grade. This does not modify any of the object’s data.

    bool Student::DisplayCourseAverage(ostream& out) const
    Prints the student’s course average to the provided output stream, rounded to 3 decimal places. Returns true if the attempt was successful, false otherwise.

    string Student::LetterGrade() const
    Returns a string with the student’s letter grade, using the same grading scale as this course.

    The class should assume that any input or output streams passed to public methods are already open.

The main program is quite simple. You are provided a data file with data for some number of students. Read the data into a vector. (Hint: Declare one student. Read that student’s data, then add it to the vector. Repeat.) It should then print a roster, showing the name, course average to 3 decimal places, and letter grade for each student in the course. This list should be sorted by student name (sort by last name, break ties using first name; display in usual first-name last-name order).

Results for the provided data file are shown. Your program will be tested against another data file with the same format.

data file 

==============================================

MIRANDA BOONE 17 17 13 17 20 86 91 71
LARRY MARSH 16 11 20 15 11 78 82 96
JANIE FOWLER 18 18 19 18 20 80 90 69
ALBERTO GILBERT 15 20 18 17 19 51 76 99
SUE LEONARD 12 15 12 18 17 85 77 100
CARL BALLARD 16 12 16 16 20 65 80 92
LESLIE PEREZ 13 18 17 12 20 81 81 96
MORRIS NEWTON 20 19 19 20 16 75 80 66
BRANDI LAMB 19 17 20 12 16 97 67 65
HERBERT HARVEY 20 16 11 14 12 80 100 80
RUDOLPH FISHER 17 18 20 18 18 82 68 77
LAURIE PHELPS 18 11 13 16 15 90 93 76
PHILIP ZIMMERMAN 17 13 18 16 18 79 78 64
BRAD HAYES 17 20 13 11 20 81 92 87
BELINDA JACKSON 18 10 16 18 16 59 76 87
JESSIE MORAN 16 14 13 19 19 78 79 66
BRIDGET KELLER 19 14 15 20 20 90 66 66
CHAD RODRIGUEZ 15 16 20 18 18 86 71 79
KENNETH KELLY 11 19 17 19 18 76 75 67
CASSANDRA MASON 14 20 18 20 17 85 76 100
RANDY JACKSON 18 19 15 19 17 67 61 65
GARRY CLAYTON 10 16 18 14 19 86 85 84
NICK FLOYD 18 13 20 17 16 79 76 81

======================================

 

expected output:

(Included in the image)

GN Microsoft Visual Studio Debug Console
CARL
MIRANDA
GARRY
RUDOLPH
NICK
JANIE
ALBERTO
HERBERT
BRAD
BELINDA
RANDY
BRIDGET
KENNETH
BRANDI
SUE
LARRY
CASSANDRA
BALLARD
79.350
C+
BOONE
83.133
В-
CLAYTON
82.200
В-
FISHER
81.033
В-
FLOYD
80.533
В-
FOWLER
84.333
B
GILBERT
80.117
В-
HARVEY
81.883
В-
HAYES
84.683
B
JACKSON
75.400
JACKSON
72.617
C-
KELLER
78.900
C+
KELLY
76.633
LAMB
79.017
C+
LEONARD
82.667
В-
MARSH
81.017
В-
MASON
87.700
B+
JESSIE
MORAN
76.667
MORRIS
LESLIE
LAURIE
CHAD
PHILIP
NEWTON
80.783
В-
PEREZ
83.900
B
PHELPS
81.667
В-
RODRIGUEZ
81.583
В-
ZIMMERMAN
76.583
Transcribed Image Text:GN Microsoft Visual Studio Debug Console CARL MIRANDA GARRY RUDOLPH NICK JANIE ALBERTO HERBERT BRAD BELINDA RANDY BRIDGET KENNETH BRANDI SUE LARRY CASSANDRA BALLARD 79.350 C+ BOONE 83.133 В- CLAYTON 82.200 В- FISHER 81.033 В- FLOYD 80.533 В- FOWLER 84.333 B GILBERT 80.117 В- HARVEY 81.883 В- HAYES 84.683 B JACKSON 75.400 JACKSON 72.617 C- KELLER 78.900 C+ KELLY 76.633 LAMB 79.017 C+ LEONARD 82.667 В- MARSH 81.017 В- MASON 87.700 B+ JESSIE MORAN 76.667 MORRIS LESLIE LAURIE CHAD PHILIP NEWTON 80.783 В- PEREZ 83.900 B PHELPS 81.667 В- RODRIGUEZ 81.583 В- ZIMMERMAN 76.583
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning