# Project #2 Solution

\$30.00 \$24.90

Category:

## Description

Background

The standard C++ library contains a container class called vector. The vector class works very much like the C# generic List class. In C++, these generic collection classes are created using “templates”, and the Vector is part of what is known as the Standard Template Library (STL).

Objective:

At the completion of this project, you will have created an application that

Gets a variable amount of input from the user,
Uses a vector to store data, and
Uses functions that you wrote.
Project

rain
Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points.

At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the median score is a good measure of the student’s overall performance on the homework assignments. The median is found by putting the homework scores in order, and then taking the score that is at the midpoint of this list. If there are an odd number of assignments, the median is the score exactly in the middle of the list. If there are an even number of assignments, the median is the average of the two scores closest to the middle.

Once the median score is known, professor Dolittle takes the sum of the exam scores and the median homework score and uses this value to compute a letter grade. Letter grades are assigned based on the following table:

381 – 400 A
361 – 380 A-
341 – 360 B+
321 – 340 B
301 – 320 B-
281 – 300 C+
261 -280 C
241 – 260 C-
221 – 240 D+
201 – 220 D
181 – 200 D-
180 and below fail
Program

Your program should work as follows:

All user input should be tested to be sure that it is a valid integer value.
It should ask the user to enter in the score for the first midterm.
This value is read in and saved.
It should ask the user to enter in the score for the second midterm.
This value is read in and saved.
It should ask the user to enter in the score for the final exam.
This value is read in and saved.
The program then asks the user to enter in the scores for the homework assignments. Any number of scores can be entered in. When done, the user signals completion by pressing Ctrl-z (the Ctrl key and the letter z, on a line all by itself) followed by the Enter key. This generates an end of file signal. (On Mac/Linux, use Ctrl-d instead.)
Store the homework scores in a vector.
Once all of the data has been entered, the program calls a function that you have written to find the median homework score.
The program then calls a function that you have written to calculate and return the letter grade.
Finally, display the median homework score, the total point count, and the letter grade.
Extra Credit

For five points, store all of the possible letter grades in a constant array of strings, and then come up with an algorithm that uses the total point count to compute an index into the array to return the letter grade. Your code cannot use a loop for this! This avoids the use of a long string of if/else statements.

Format and document your code in accordance with the course style guidelines. Include a file prologue identifying you as the author. Submit your project using the instructions outlined in the Course Syllabus, Programming Projects section.

After you are satisfied that your program works correctly, submit it to Canvas as project #2. Create a zip file for this project and include the following:

The source code for your driver.
A screen shot of your execution results.
Hints

If you need some hints to solve this problem, check here.

Source code files contain a declaration that you did not copy any code
Project has been submitted to Canvas
Code meets style guidelines
Code is properly documented
5
Your program prompts the user for three exam scores, and stores the input values in appropriately defined variables. The user’s input is checked to make sure that only valid integer values are input.

5
Your program then prompts the user to enter in a number of homework scores, terminating the input with Ctrl-z. The scores are read in and stored in a vector. Reading stops when the end of file signal generated by Ctrl-z is encountered. The user’s input is checked to make sure that only valid integer values are input.

5
Your program calls a function, written by you, that correctly calculates and returns the value of the median homework score.

5
Your program calls a function, written by you, that correctly calculates and returns a letter grade based on the exam and homework scores.

5
Your program correctly prints out the results.

5
(Extra Credit: Your program calculates an index into an array to determine the letter grade.)

(5)
-Late penalty (-20% per day)

Total

30
Sample Output: