CSCI 261 - Programming Concepts - Summer 2019

A7 - Average Grades

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:

Name:        Peter Parker
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

  1. Determine the average grade of each student.
  2. Count the number of students taking undergraduate and graduate level courses.
  3. 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).

Using the provided input file, your output file should include:

Name: Parker, Peter
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.

  1. Start a new project from scratch.
  2. Declare an ifstream object associated with the input file; Verify that you opened the file.
  3. Also declare an ofstream object associated with an output file called output.txt.
  4. Loop through the input file with an EOF while loop.
  5. Read each record in the file.
  6. Format the name to match the output format
  7. 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);
  8. Read the scores into a vector of type double and use the scores to find the average.
  9. Format the data from the input file as required for the output file.
  10. 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.
  11. 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.
  12. Close both input and output files.

Grading Rubric


Your submission will be graded according to the following rubric.

PointsRequirement 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.


It is critical that you follow these steps when submitting homework.

If you do not follow these instructions, your assignment will receive a major deduction. Why all the fuss? Because we have several hundred of these assignments to grade, and we use computer tools to automate as much of the process as possible. If you deviate from these instructions, our grading tools will not work. And that makes us very unhappy. And when we're unhappy, we give penalties. Thus, make us happy.


Submission Instructions



Here are step-by-step instructions for submitting your homework properly:
  1. File and folder names are extremely important in this process. Please double-check carefully, to ensure things are named correctly.
    1. The top-level folder of your project must be named Set7
    2. 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, and A7).
    3. Copy your main.cpp , additional header & source files () plus the CMakeLists.txt file into the subdirectories of Set7 (steps 1-2), zip this Set7 folder (steps 3-4), and then submit the zipped file (steps 5-11) to Canvas.
    4. For example, when you zip/submit Set7, there will be 2 sub-folders called L7A, and A7 inside the Set7 folder, and each of these sub-folders will have a file called main.cpp, additional header & source files, plus the CMakeLists.txt file .

  2. 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?

  3. Now, for A7, right click on the main.cpp to copy the file. Then, return to the Set7/A7 folder and right click to paste the file. In other words, put a copy of your homework's main.cpp source code into the Set7/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's main.cpp into the Set7/L7A folder.

    STOP: Are you sure your Set7 folder now has all your code to submit?

  4. Now, right-click on the "Set7" folder.
    1. In the pop-up menu that opens, move the mouse "Send to..." and expand the sub-menu.
    2. In the sub-menu that opens, select "Compressed (zipped) folder".

    STOP: Are you really sure you are zipping a Set7 folder with sub-folders that each contain a main.cpp file in it?

  5. After the previous step, you should now see a "Set7.zip" file.

  6. Now visit the Canvas page for this course and click the "Assignments" button in the sidebar.

  7. Find Set7, click on it, find the "Submit Assignment" area, and then click the "Choose File" button.

  8. 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?

  9. WAIT! There's one more super-important step. Click on the blue "Submit Assignment" button to submit your homework.

  10. 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!

  11. 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!
In summary, you must zip the "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 .