what input file are you speaking of?
I'm hoping you can help me with this C++ program. As I am in beginning C++, this seems very overwhelming based on the amount of pages to take in. There isn't any rush, if you can go through it thoroughly. Please show code based on specifications. Thank you in advance for your help.
CS 210 Lab 7 Specifications Checkpoint due 11:59PM Fri Mar 1 Lab Due 11:59PM Tue Mar 5 Lab 7 Overview: In Lab 4 you wrote a program to produce a report based on the data in the classData.dat file that contains student's names and test scores. In this lab, you will again process the data in the classData.dat file (or shortClassData.dat), but you will do so in a very different way Each student's information will be stored in a StudentRecord object which contains the student's name and an array of their test scores Your program will manage an array of StudentRecord objects You will implement some elementary exception-handling code . . . . This will eventually be a multi-file project containing files named StudentRecord.h StudentRecord.cpp, and StudentGradeReport.cpp. You will write this program in stages. You are strongly discouraged from p before completing the earlier stages. to another stage Lab 7 Stage 1 (Checkpoint): If you have not already done so, download and unzip the compressed Lab7Files folder. It contains a file named Lab7Driver.cpp that is a template for your Stage-1 Checkpoint code. That code should fill and display an array of StudentRecord objects populated with the student data in the shortClassData.dat file. This shorter version of the classData.dat file contains only 5 students with 2 test scores each. When you have completed Stage 1, your program should be capable of generating the following I/O session Number of students in CS 210: 5 ACOSTA BRANDON M 1 APOLISTA TRIXIA 2 BOBBY ANTHONY J 91.868.80.0 50.1 65.0 0.0 72.778.50.0 98.351.70.0 70.190.80.0 BOESEL MITCHALL R BONSEN CHLOEE This report displays the course title, the number of students in the class, and the names, two test scores and average test score for each student. As you can see, the average score is just 0 at this stage Take a moment to study the Lab7Driver.cpp file located in the Lab7Files folder. You will see that it will be organized as follows for Stage1 # include 2. Declaration of StudentRecord class interface that will eventually be moved to StudentRecord.h file 3. using namespace std; 4. DefinitionMmplementation code for StudentRecord member functions that will eventually be moved to StudentRecord.cpp file 5. const int MAX_STUDENTS50 6. main ) function test driver code In Stage 1 you should create the class declaration and implementation code for the StudentRecord class defined in the modified UML class diagram below StudentRecord Data Members Description +static const in MAX TESTS This global class constant should be initialized to 8 to indicate that the maximum number of tests that can be accommodated at this time is 8. See lines 13 and 14 of the Gradebook.h file shown in 7.9 on page 312 for how to declare and initialize a class constant. numTests contains the actual number of tests taken by the student. -int numTests string name The name of the student The scores array will hold the student's test scores. It may be only partially filled. The numTests data member field gives the actual number of tests taken by the student. array
SCores double avgScore The student's average test score. This will be determined by the client program because only the client program can DO NOT DECLARE ANY OTHER DATAknow the grading scheme used in a particular course MEMBER FIELDS FOR THIS CLASS Member Function Prototypes Description "set" functions Assigns the name data member field the value of the parameter. You must choose the parameter's name. +void setName (std::string) Assigns the avgScore data member field the value of the parameter. You must choose the parameter's name. +void setAverageScore (double) The setNumTests () function should assign the numTests data member field the value of the parameter UNLESS the parameter value is not between 0 and MAX_TESTS. In that case, the setNumTests() function should throw an invalid_Argument exception passing an appropriate error message argument as shown in Time.cpp in 9.6 on page 401. You must choose the parameter's name +void setNumTests (int); The setScore () function should assign the scores [index] data member field the value of the newVal parameter UNLESS the index value is not between 0 and numTests. In that case, the setScore () function should throw an invalid Argument exception passing an appropriate error message argument. void setScore (int index, double newVal) StudentRecord continued Member Function Prototypes Description Constructors +StudentRecord )i This default constructor should initialize all data member number fields to 0 and the name field to theempty string. Use an initializer list only, leaving the function body empty OR make sure all the data fields are initialized when they are declared in the private section of the class, in which case the entire default constructor can be empty-but it must be defined either way +StudentRecord (int testsTaken, This second constructor will attempt to read the data for a student from the infile input stream parameter. It assumes that the pointer into the input stream buffer is at the beginning of a line containing the name of a student-or at the end of the file, possibly on a blank line. It should perform the following tasks: Estream& infile, bool& successful) Use the getline() function to read the name from the file into a temporary local string variable If the name read from the file was the empty string . . Set successfulto false return out of the constructor o o OTHERWISE Call the setName() function to set the name field to the name you read from the file o .Call the setNumTests ) function to set the numTests data field to the value of the testsTaken parameter Use a correctly constructed for-loop controlled by the testsTaken parameter to do the following . Use the >> operator to read a score from the o file into a temporary local double variable. o Call the setScore function appropriately so that the correct scores[?] element will be set to the score you just read from the file Consume the in the file stream that follows the last score that was just read from the stream. .Call the function setAverageScore() to set the avgScore data field to 0.0 "get" functions tint getNumTests) consti +string getName const: +double getAverageScore()const; Returns the value of the numTests data member field. Returns the value of the name data member field Returns the value of the avgScore data member field. StudentRecord continued Member Function Prototypes Description "get" functions continued +double getScore (int index) const The getScore) function should return the value in scores [index] UNLESS the index value is not between 0 and the value retumed by calling getNumtests () appropriately. In that case, the getScore) function should throw an invalid_Argument exception passing an appropriate error message argument. Other member functions void showStudent ()consti This showStudent ) function displays the StudentRecord object on the console screen as follows: Display the name, left-justified in 25 spaces. . Use the fixed and setprecision VO manipulators to assure that all scores will be displayed with exactly one digit right of the decimal point . . Use an appropriate for-loop to display right-justified in 6 spaces the value returned by calling the getSco After displaying the individual test scores, display right-justified in 6 spaces the value returned by calling the getAverageScore() function appropriately followed by endl re () function appropriately End Checkpoint (Lab 7 Stage 1) Specifications Lab 7 Stage 2: Appropriately prototype and implement a member function of the StudentRecord class described below double scoreTotal) const: //member function prototype This scoreTotal function should compute and return the sum of the scores in the StudentRecord object. It should achieve this goal by calling the getScore function appropriately instead of accessing scores[?] directly. That is, we will follow Software Engineering Observation 9.5 on page 404 of 9.6.1. This function does not display anything. Add code to the main) function of Lab7Driver.cpp so that it displays the following VO session by calling the scoreTotal ) function appropriately Number of students in CS 210: 5 0 ACOSTA BRANDON M 91.868.80.0 Total score: 160.6 BOESEL MITCHALL R 98.351.70.0 Total score: 150.1 BONSEN CHLOEE 70.190.80.0 Total score: 160.9 Lab 7 Stage 5: It is time to separate the class interface, the class implementation code, and the class test driver code into separate header, implementation and client driver files as discussed in 9.2.1-9.2.12. You should make a backup of your Stage 4 Lab7Driver.cpp file before proceeding The header file containing the StudentRecord interface should be named StudentRecord.h. . The header file should contain inclusion guard pre-compiler directives such as is shown in Figure 9.1 on page 389 in 9.2.3. Chose a more appropriate name than TIME H o The file containing the StudentRecord implementation code should be named . StudentRecord.cpp. . The file containing the client test driver code should be named Lab7Driver.cpp. . Both cpp files must include "StudentRecord.h" . Both cpp files can have using namespace std; .Once the code is separated into interface, implementation, and client driver files, you must create a program project and add the three files to the project so that you are able to compile each file and run the driver program. The project containing the separated files should produce the same results as the single-file Stage-4 program did. NOTE: If you can't get Stage 5 working correctly, you can proceed to Stage 6 using your single-file Stage 4 program, but you will have to be careful to not confuse the member functions with the non- member functions described in Stage 7 Lab 7 Stage 6: Section As you know, cout is the standard output stream. Objects of class ostringstream (from the header ) provide the same functionality, but write their output to string objects in memory. You use the ostringstream's str member function to get the formatted string 9.2.8 says the following: Use this information to prototype and implement the following StudentRecord member function. string toString ) const: //member function prototype This function creates and returns a printable version of a StudentRecord object that is formatted the same way as the showStudent ) function. The function accomplishes this by doing everything the showStudent () function does, except that instead of inserting ( SCores double avgScore The student's average test score. This will be determined by the client program because only the client program can DO NOT DECLARE ANY OTHER DATAknow the grading scheme used in a particular course MEMBER FIELDS FOR THIS CLASS Member Function Prototypes Description "set" functions Assigns the name data member field the value of the parameter. You must choose the parameter's name. +void setName (std::string) Assigns the avgScore data member field the value of the parameter. You must choose the parameter's name. +void setAverageScore (double) The setNumTests () function should assign the numTests data member field the value of the parameter UNLESS the parameter value is not between 0 and MAX_TESTS. In that case, the setNumTests() function should throw an invalid_Argument exception passing an appropriate error message argument as shown in Time.cpp in 9.6 on page 401. You must choose the parameter's name +void setNumTests (int); The setScore () function should assign the scores [index] data member field the value of the newVal parameter UNLESS the index value is not between 0 and numTests. In that case, the setScore () function should throw an invalid Argument exception passing an appropriate error message argument. void setScore (int index, double newVal) StudentRecord continued Member Function Prototypes Description Constructors +StudentRecord )i This default constructor should initialize all data member number fields to 0 and the name field to theempty string. Use an initializer list only, leaving the function body empty OR make sure all the data fields are initialized when they are declared in the private section of the class, in which case the entire default constructor can be empty-but it must be defined either way +StudentRecord (int testsTaken, This second constructor will attempt to read the data for a student from the infile input stream parameter. It assumes that the pointer into the input stream buffer is at the beginning of a line containing the name of a student-or at the end of the file, possibly on a blank line. It should perform the following tasks: Estream& infile, bool& successful) Use the getline() function to read the name from the file into a temporary local string variable If the name read from the file was the empty string . . Set successfulto false return out of the constructor o o OTHERWISE Call the setName() function to set the name field to the name you read from the file o .Call the setNumTests ) function to set the numTests data field to the value of the testsTaken parameter Use a correctly constructed for-loop controlled by the testsTaken parameter to do the following . Use the >> operator to read a score from the o file into a temporary local double variable. o Call the setScore function appropriately so that the correct scores[?] element will be set to the score you just read from the file Consume the in the file stream that follows the last score that was just read from the stream. .Call the function setAverageScore() to set the avgScore data field to 0.0 "get" functions tint getNumTests) consti +string getName const: +double getAverageScore()const; Returns the value of the numTests data member field. Returns the value of the name data member field Returns the value of the avgScore data member field. StudentRecord continued Member Function Prototypes Description "get" functions continued +double getScore (int index) const The getScore) function should return the value in scores [index] UNLESS the index value is not between 0 and the value retumed by calling getNumtests () appropriately. In that case, the getScore) function should throw an invalid_Argument exception passing an appropriate error message argument. Other member functions void showStudent ()consti This showStudent ) function displays the StudentRecord object on the console screen as follows: Display the name, left-justified in 25 spaces. . Use the fixed and setprecision VO manipulators to assure that all scores will be displayed with exactly one digit right of the decimal point . . Use an appropriate for-loop to display right-justified in 6 spaces the value returned by calling the getSco After displaying the individual test scores, display right-justified in 6 spaces the value returned by calling the getAverageScore() function appropriately followed by endl re () function appropriately End Checkpoint (Lab 7 Stage 1) Specifications Lab 7 Stage 2: Appropriately prototype and implement a member function of the StudentRecord class described below double scoreTotal) const: //member function prototype This scoreTotal function should compute and return the sum of the scores in the StudentRecord object. It should achieve this goal by calling the getScore function appropriately instead of accessing scores[?] directly. That is, we will follow Software Engineering Observation 9.5 on page 404 of 9.6.1. This function does not display anything. Add code to the main) function of Lab7Driver.cpp so that it displays the following VO session by calling the scoreTotal ) function appropriately Number of students in CS 210: 5 0 ACOSTA BRANDON M 91.868.80.0 Total score: 160.6 BOESEL MITCHALL R 98.351.70.0 Total score: 150.1 BONSEN CHLOEE 70.190.80.0 Total score: 160.9 Lab 7 Stage 5: It is time to separate the class interface, the class implementation code, and the class test driver code into separate header, implementation and client driver files as discussed in 9.2.1-9.2.12. You should make a backup of your Stage 4 Lab7Driver.cpp file before proceeding The header file containing the StudentRecord interface should be named StudentRecord.h. . The header file should contain inclusion guard pre-compiler directives such as is shown in Figure 9.1 on page 389 in 9.2.3. Chose a more appropriate name than TIME H o The file containing the StudentRecord implementation code should be named . StudentRecord.cpp. . The file containing the client test driver code should be named Lab7Driver.cpp. . Both cpp files must include "StudentRecord.h" . Both cpp files can have using namespace std; .Once the code is separated into interface, implementation, and client driver files, you must create a program project and add the three files to the project so that you are able to compile each file and run the driver program. The project containing the separated files should produce the same results as the single-file Stage-4 program did. NOTE: If you can't get Stage 5 working correctly, you can proceed to Stage 6 using your single-file Stage 4 program, but you will have to be careful to not confuse the member functions with the non- member functions described in Stage 7 Lab 7 Stage 6: Section As you know, cout is the standard output stream. Objects of class ostringstream (from the header ) provide the same functionality, but write their output to string objects in memory. You use the ostringstream's str member function to get the formatted string 9.2.8 says the following: Use this information to prototype and implement the following StudentRecord member function. string toString ) const: //member function prototype This function creates and returns a printable version of a StudentRecord object that is formatted the same way as the showStudent ) function. The function accomplishes this by doing everything the showStudent () function does, except that instead of inserting (