can you provide code for this, I would like to use it as reference to figure out what I'm missing on my end. I need the full code. if you are going to tell me it's to long, don't bother. that won't help me, I need the code A.S.A.P please and thank you.
here is the lab7driver.cpp if you need, otherwise don't worry about this
/* PROGRAMMER: DESCRIPTION: Lab 7 Stage 1 (Checkpoint) This file contains code that *Declares Stage 1 of the StudentRecord class interface. This code will eventually be moved to the StudentRecord.h file. *Defines Stage 1 of the StudentRecord class. This code will eventually be moved to the StudentRecord.cpp file. *Code that tests the Stage 1 StudentRecord member functions. */ #include #include #include #include #include #include
/* The class declaration code that you will write below will eventually be moved to the StudentRecord.h file. ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION !!! Be sure to use the std:: qualifier on any references to array or string data types inside the class interface. !!! */ class StudentRecord { public: //Declare the Stage-1 public constant here. //Declare the Stage-1 constructor PROTOTYPES here. //Declare the Stage-1 "get" and "set" member function PROTOTYPES here. //Declare other Stage-1 member function PROTOTYPES here. private: //Declare four Stage-1 data members here. };
using namespace std;
/* The implementation code that you will write below for the StudentRecord member functions will eventually be moved to the StudentRecord.cpp file. Don't forget to use the StudentRecord:: qualifier in front of each member function name!!! */
//Define the Stage-1 StudentRecord contructors here.
//Define the Stage-1 accessor "get" functions here.
//Define the Stage-1 mutator "set" functions here.
//Define other Stage-1 member functions here.
const int MAX_STUDENTS{ 50 };
int main() { //Create an array of 50 default StudentRecord objects. array students; fstream classDataFile("shortClassData.dat", ios::in); //The input file contains the class data
if (classDataFile.fail()) { cout
//Input the class title and number of tests given string courseTitle, consumeN; int numTests; getline(classDataFile, courseTitle); classDataFile >> numTests; getline(classDataFile, consumeN); //Consume in input stream int stuCount{ 0 }; bool inputOperationSuccessful{ false };
//Input student data do { //Construct a new StudentRecord object with data input from the classDataFile stream. //This will not be successful when the end of the file is reached. StudentRecord newStu{ numTests, classDataFile, inputOperationSuccessful }; if (inputOperationSuccessful) { //Put the newStu StudentRecord object into the next available array location. students[stuCount] = newStu; stuCount++; } } while (inputOperationSuccessful);
//Make sure data was correctly read from file. cout
system("pause"); return 0; }
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 3: Appropriately prototype and implement a member function of the StudentRecord class described below double lowestScore) const: //member function prototype This lowestScore) function should determine and return the lowest of the scores in the StudentRecord object. It should achieve this goal by calling the getScore function appropriately instead of accessing scores ?] directly. This function does not display anything Add code to the main) function of Lab7Driver.cpp so that it displays the following I/O session by calling the lowestScore () function appropriately Number of students in CS 210: 5 0 ACOSTA BRANDON M Lowest 1 APOLISTA TRIXIA 91.868.80.0 Total score: 160.6 score: 68.8 50.1 65.0 0.0 Total score: 115.2 Lowest score: 50.1 BONSEN CHLOEE 70.190.80.0 Total score: 160.9 est score: 70.1 Lab 7 Stage 4: Add code to the main) function of Lab7Driver.cpp so that it will determine set and display the average score for each StudentRecord object in the array. As in Lab 4, the average score should be computed by dropping the lowest score-unless there was only one score in which case the average score is just the total score. The main function should perform this task by appropriately calling the getNumTests scoreTotal lowestScore setAverageScore and getAverage) member functions appropriately When the program runs it should generate the following IVO session, where the average score is displayed on the same line as the student's individual test scores Number of students in CS 210: 5 0 ACOSTA BRANDON M 91.868.891.8 Total score: 160.6 Lowest score: 68.8 BONSEN CHLOEE 70.190.890.8 Total score: 160.9 Lowest score: 70.1 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 3: Appropriately prototype and implement a member function of the StudentRecord class described below double lowestScore) const: //member function prototype This lowestScore) function should determine and return the lowest of the scores in the StudentRecord object. It should achieve this goal by calling the getScore function appropriately instead of accessing scores ?] directly. This function does not display anything Add code to the main) function of Lab7Driver.cpp so that it displays the following I/O session by calling the lowestScore () function appropriately Number of students in CS 210: 5 0 ACOSTA BRANDON M Lowest 1 APOLISTA TRIXIA 91.868.80.0 Total score: 160.6 score: 68.8 50.1 65.0 0.0 Total score: 115.2 Lowest score: 50.1 BONSEN CHLOEE 70.190.80.0 Total score: 160.9 est score: 70.1 Lab 7 Stage 4: Add code to the main) function of Lab7Driver.cpp so that it will determine set and display the average score for each StudentRecord object in the array. As in Lab 4, the average score should be computed by dropping the lowest score-unless there was only one score in which case the average score is just the total score. The main function should perform this task by appropriately calling the getNumTests scoreTotal lowestScore setAverageScore and getAverage) member functions appropriately When the program runs it should generate the following IVO session, where the average score is displayed on the same line as the student's individual test scores Number of students in CS 210: 5 0 ACOSTA BRANDON M 91.868.891.8 Total score: 160.6 Lowest score: 68.8 BONSEN CHLOEE 70.190.890.8 Total score: 160.9 Lowest score: 70.1 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 (