(Solved) : Program Read Data Text File Produce Grade Report Data Text File Contain Class Id Title Num Q34497970
This program will read data from a text file to produce a gradereport. The data in the text file will contain the class ID (ortitle), the number of tests given in the class, and a list ofstudents and their test scores. The report will include most of thedata from the file, plus some calculated values such as eachstudent’s average test score after their lowest score is dropped,the number of students in the class, the class average and thehighest average score in the class. I’ve spent three times longeron this than I probably should have. I’m just a beginner looking tolearn C++. Please Help.
CS 210 Lab 4 Program Specifications Checkpoint due 11:59PM Sat Feb 2, 2019 Lab due 11:59 PM Wed Feb 6, 2019 Program Overview: This program will be a single-file project-no-h class definition file. You will write a program in a file named ClassReport.cpp that will read data from a text file to produce a grade report. The data in the text file will contain the class ID (or title), the number of tests given in the class, and a list of students and their test scores. The report will include most of the data from the file, plus some calculated values such as each student’s average test score after their lowest score is dropped, the number of students in the class, the class average and the highest average score in the class. This lab will give you more practice formatting output, and it will introduce you to using while-loops and for-loops. Output Report Specifications: Your ClassReport.cpp program will read data from a text file to produce the grade report partially shown below CS 210 Student Name Tl T2 3 T4 TSAvg ANTER ZACHARY L ARREOLA JUAN J BARBER ANTONIO D 91.8 68.8 73.1 87.4 51.1 80.3 50.1 65.0 61.3 59.3 90.0 68.9 72.7 78.5 89.6 91.8 91.3 87.8 YOKOTA YUSUKE YOUNG NICHOLAS T ZAVALA ROGELIO R 1.3 88.9 93.0 88.7 78.6 87.3 86.9 56.2 99.3 55.2 65.7 77.0 5.4 58.2 92.6 74.1 82.2 81.1 Number of Students: 31 Class Average: 79.1 Class High Average: 94.0 Input Text File Data Specifications: The data file posted with this assignment is named classData.dat The layout or format of the file will be as follows: Data Value Course ID Number of tests Name of student #1 Student #1’s test scores Description The first line in the file holds the ID (Title) for the course The second line in the file holds number of tests given in the class. The third line in the file holds the first student’s name Each score is separated from the next with whitespace. E.g Score1 Score2 Score3 etc. Pattern repeats with name/scores pairs of lines in the file Score1 Score2 etc. (As many scores as were given in the class.) Name of student #2 Student #2’s test scores Name of student #N Student #N’s test scores You may assume that any file named classData.dat will conform to the layout described above Last student’s name in the file Score1 Score2 etc. but you may not assume that the course ID will always be CS 210, or that the number of tests will always be 5, or that there will always be 31 students listed, as is the case with the classData.dat file that was posted with this assignment. A portion of the file’s data is shown below: CS 210 ANTER ZACHARY L 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Please note that a random number generator was used in an Excel spreadsheet to generate the simulated test scores, so don’t be insulted if your name is given with lousy scores! Other Considerations and Requirements The Lab4Files folder posted with this assignment contains the classData.dat file. You may look at the file using your IDE’s File Open menu option. For most IDEs, you should store the classData.dat file in the same folder as the ClassReport.cpp file. (If that doesn’t work, try storing it in the same folder as your project file.) . .After opening the classData.dat file for input, be sure to test that the operation was successful using code similar to that shown on lines 37-40 in the Read Accounts2.cpp program posted in the Lab4Files folder. If your data file isn’t successfully opened, then no other code you write will work! Everything depends on you being able to open the file and read the data from it correctly. Get your checkpoint code described in the next section of this document to work before attempting any other processing! The report generated by your program should reflect the contents of the classData.dat file. If the contents of the data file change, the contents of the report should change accordingly . . You may assume the following: 1 S the number of tests s 8. That is, there is guaranteed to be at least one test score per student, and there won’t be more than 8 scores, so they will all fit on the 80-character wide console screen along with the average score if you follow the related formatting specs below Your program should end up with a for-loop nested inside a while-loop. . Display each score and average score right-justified in a field width of 6 characters, displaying exactly one digit to the right of the decimal point. Display each name left-justified in a field-width of 25 characters-you may assume no name in the data file will be longer than 25 characters Drop each student’s lowest score before computing their average score, unless there was only one test given in the class-then the average score for that student is simply their only test The course title is centered within the 80-character width of the console screen. HINT: Fig 5.8 on page 176 demonstrated the size) attribute of a string object. You can do some math on that as the parameter of the setw) VO manipulator introduced in Fig 5.6 on page 168 . Column headings appear above the names, scores and averages as shown in the report above. . . 80 characters are displayed above and below the detail lines of the report as shown in the report above The program computes and displays the number of students in the class in the summary at the bottom of the report as shown above . The program computes and displays the average average-score in the summary at the bottom of the report as shown above . The program computes and displays the highest average-score in the summary at the bottom of the report as shown above . The program must use appropriate style as itemized in the StyleSpecifications.pdf file posted in the Quick Links module on Canvas. SUGGESTION: The last thing you should worry about is nicely formatting the report. First get your program to read the data correctly. Then get it to produce correct computations. Only after that is done should you worry about making things look pretty Lab 4 Checkpoint Specifications The checkpoint version of your ClassReport.cpp program should echo the input from the data file to the screen, and display the number of students in the class. A portion of that output is shown below CS 210 number of tests:5 ANTER ZACHARYL 91.78 68.78 73.09 87.36 51.08 ARREOLA JUAN J 50.15 65.04 61.32 59.27 89.99 YOUNG NICHOLAS T 86.92 56.22 99.3 55.24 65.69 ZAVALA ROGELIO R 75.43 58.19 92.56 74.14 82.25 Number of Students: 31 Text File Input Considerations Mixing Extraction Operations >) with getline): Study the Read_Accounts1.cpp and Read Accounts2.cpp programs posted with this assignment. They demonstrate how to open a file for input, and how to keep reading from the file until all its data has been read. You will see that it’s as easy to read from a text file as it is to read from the keyboard (cin). That is, you use the same extraction (>> and getline) operations no matter what input stream you are reading from. For the sake of discussion, suppose your program contains the following code to open a file for input: fstream classDataFile(“classData.dat”, ios::in) Here’s what’s really in the classDataFile input file stream: CS 210n5 nANTER ZACHARY Ln 91.78 68.78 73.09 87.36 51.08 nARREOLA JUAN J That is, it is a stream of characters, some of which are whitespace such asor’n REMEMBER Warning 2 from Lab 2: The >> extraction operator ignores whitespace as it tries to extract numeric or character or string data from the input stream. If you don’t want whitespace to be ignored as in the case of the space between CS and 210, or the space between first name and last name, and last name and middle initial, then you must use getline). Remember that this combination of input operations may require you to do two getline ) operations (or some of you have used ignore)). The first getline) will consume the ln following the last score on each line, and the second getline) will actually input the name Text file End-of-data Weirdness: Sometimes the last line of data in a text file does not contain an end-of-line (n) marker. This can happen when users type the data on the last line of the file and don’t hit the enter key before they close the file. Alternatively, the user may hit the enter key several times at the end of a file so that there are multiple blank lines at the end of the file. This would result in an input data stream that looks like the following: cs 2101n5nANTER ZACHARY LinZAVALA ROGELIO RIn75.43 58.19 92.56 74.14 82.25 nnnin In either case, the last line of a text file can cause challenges, especially when the program uses a mix of extraction (>> and getline() operations. This is why the while-loop in the Read Accounts2.cpp file posted with this assignment contains the following condition: while( getline (inClientFile, name) &&name”) In English, this translates into “While it is possible to input a line of characters from the inClientFile input stream for the name variable, and that name isn’t the empty string In other words, a getline() operation may report success even though all it successfully input was an empty string! For this lab, that is not success, so the loop should terminate Note to Mac and Unix/Linux Users: The Mac and Unix OS use different end-of-line markers in their text files. Be sure to use a native text editor to open the data files I post and save them so that they will contain the native end-of-line markers used on your systems Show transcribed image text
Attached . . .