This assignment is due by Tuesday, June 11, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A
.
· Instructions · Rubric · Submission ·
Concepts
In this homework, we will continue to practice file I/O and data manipulation.
Working with Data
The given input file has records that look like this:
CSCI-261: 95
CSCI-262: 90.625
CSCI-442: 91.20
Name: Mary Smith
CSCI-442: 65.0
CSCI-562: 79.1234
CSCI-580: 70.24
Our goal is to loop through the file, and
- Determine the average grade of each student.
- Count the number of students taking undergraduate and graduate level courses.
- Count the number of students taking each course.
Undergraduate and graduate level courses - Courses 500 and above are graduate level courses. The rest are undergraduate level courses.
Identifying various courses - The following lists the courses offered by the CS program at Mines, as well as their abbreviations (which you need for Step 3).
- CSCI-261: Programming Concepts
- CSCI-262: Data Structures
- CSCI-306: Software Engineering
- CSCI-442: Operating Systems
- CSCI-562: Applied Algorithms & Data Structures
- CSCI-565: Distributed Computing Systems
- CSCI-580: Advanced High Performance Computing
Using the provided input file, your output file should include:
Average Score: 92.27
Name: Smith, Mary
Average Score: 71.45
.....
There are 18 instances of students taking undergraduate level courses.
There are 12 instances of students taking graduate level courses.
CSCI-261: Programming Concepts has 4 students.
CSCI-442: Operating Systems has 5 students.
Putting it all together
Download the provided text file that contains example input records. (Place this file at the project level, which is the same directory as your main.cpp file. Then follow these steps.
- Start a new project from scratch.
- Declare an
ifstream
object associated with the input file; Verify that you opened the file. - Also declare an
ofstream
object associated with an output file calledoutput.txt
. - Loop through the input file with an EOF while loop.
- Read each record in the file.
- Format the name to match the output format
- For each of the courses, use the first part (e.g., CSCI-442) to identify the course. You then need to count the number of students in each course;
since there are seven courses in total, perhaps create an array with seven elements.
Hint: Write a function that takes a string as an input and returns an integer as an output. For example, if the input to the function is CSCI-261 then the output is 0. If the input is CSCI-562, then the output is 4. You can use the different course numbers in a switch statement to return the position within the array when ordered numerically. For example, perhaps have:
int getCourseNumberIndex(string course);
- Read the scores into a vector of type double and use the scores to find the average.
- Format the data from the input file as required for the output file.
- Write the formatted output to the output file. You can update the output file after each student’s details are read and his/her average calculated. Note that the average in the output file contains exactly two decimal places.
- You need to calculate the number of students per course, as well as the number of students in graduate and undergraduate level courses during your loop; however, you need to write these details to your output file after the loop has ended.
- Close both input and output files.
Grading Rubric
Your submission will be graded according to the following rubric.
Points | Requirement Description |
2 | All code submitted properly. |
2 | All labs completed and submitted L7A |
5 | Input file opened and read correctly. |
6 | Output file opened and written in the proper format. |
2 | Output file data is correct based on public test case. |
4 | Output file data is correct based on private test case. |
2 | (1) Comments used (2) Coding style followed (3) Appropriate variable names, constants, and data types used (4) Instructions followed |
23 | Total Points |
This assignment is due by Tuesday, June 11, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A
.
Submission
Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available. The following instructions are copied from How to Submit Homework.
Submission Instructions
- File and folder names are extremely important in this process.
Please double-check carefully, to ensure things are named correctly.
- The top-level folder of your project must be named
Set7
- Inside
Set7
, create 2 sub-folders that are required for this Set. The name of each sub-folder is defined in that Set (e.g.L7A
, andA7
). - Copy your
main.cpp
, additional header & source files () plus the
CMakeLists.txt
file into the subdirectories ofSet7
(steps 1-2), zip thisSet7
folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas. - For example, when you zip/submit
Set7
, there will be 2 sub-folders calledL7A
, andA7
inside theSet7
folder, and each of these sub-folders will have a file calledmain.cpp
, additional header & source files, plus the CMakeLists.txt file .
- The top-level folder of your project must be named
- Using Windows Explorer (not to be confused with Internet Explorer), find the file
named
"main.cpp"
located inside the folder for the particular lab or homework assignment you will submit.
STOP: Are you really sure you are viewing the correct assignment's folder?
- Now, for A7, right click on the
main.cpp
to copy the file. Then, return to theSet7/A7
folder and right click to paste the file. In other words, put a copy of your homework'smain.cpp
source code into theSet7/A7
folder. Repeat this for each additional header & source file you have with this assignment, plus CMakeLists.txt.
Follow the same steps for L7A, to put a copy of your lab'smain.cpp
into theSet7/L7A
folder.
STOP: Are you sure yourSet7
folder now has all your code to submit?
- Now, right-click on the
"Set7"
folder.- In the pop-up menu that opens, move the mouse
"Send to..."
and expand the sub-menu. - In the sub-menu that opens, select
"Compressed (zipped) folder"
.
STOP: Are you really sure you are zipping aSet7
folder with sub-folders that each contain amain.cpp
file in it?
- In the pop-up menu that opens, move the mouse
- After the previous step, you should now see a
"Set7.zip"
file.
- Now visit the Canvas page for this course
and click the
"Assignments"
button in the sidebar.
- Find Set7, click on it, find the
"Submit Assignment"
area, and then click the"Choose File"
button.
- Find the
"Set7.zip"
file created earlier and click the"Open"
button.
STOP: Are you really sure you are selecting the right homework assignment? Are you double-sure?
- WAIT! There's one more super-important step. Click on the blue
"Submit Assignment"
button to submit your homework.
- No, really, make sure you click the
"Submit Assignment"
button to actually submit your homework. Clicking the"Choose File"
button in the previous step kind of makes it feel like you're done, but you must click the Submit button as well! And you must allow the file time to upload before you turn off your computer!
- Canvas should say "Submitted!". Click "Submission Details" and you can download the zip file you just submitted. In other words, verify you submitted what you think you submitted!
"Set7"
folder
and only the "Set7"
folder, this zip folder must have several sub-folders, you must name all these folders correctly, you must submit the correct zip file for this
homework, and you must click the "Submit Assignment"
button. Not doing these steps is like bringing your
homework to class but forgetting to hand it in. No concessions will be made for
incorrectly submitted work. If you incorrectly submit your homework, we will not be able to
give you full credit. And that makes us unhappy. This assignment is due by Tuesday, June 11, 2019, 11:59 PM.
As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must be provided in accordance with the course collaboration policy.
Do not forget to complete the following labs with this set: L7A
.