Vectors and Arrays Solution

$35.00

Description

Background

The standard C++ library contains a container class called vector. The vector class works very much like lists in C#, Java, and other languages. In C++, generic collection classes are created using “templates”, which we’ll see at the end of the course.

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 — Find the Median and Record the Grade

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 midpoint of the data.

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. The sum is is truncated to the next integer down if it has a fraction (so 180.7 is a 180 for grading purposes). Letter grades are assigned based on the following table:

Program Requirements

Your program should work as follows:

  1. All user input should be tested to be sure that it is a valid integer value in the range 0 to 100.

  1. It should ask the user to enter in the score for the first midterm. Then this value is read in and saved.

  1. It should ask the user to enter in the score for the second midterm. Then this value is read in and saved.

  1. It should ask the user to enter in the score for the final exam. Then this value is read in and saved.

  1. The program then asks the user to enter in the scores for the homework assignments. Any number of scores can be entered in. You will test for a -1 entry to stop adding to the vector.

  1. Store the homework scores in a vector.

  1. Once all of the data has been entered, the program calls a function that you have written to find the median homework score.

  1. The program then calls a function that you have written to calculate and return the letter grade. The return grade is based upon the total of the three exams plus the median homework score (total points).

  1. Finally, display the median homework score, the total point count, and the letter grade.

Dr. DoLittle’s Grading Program …..

Please enter in the score for the first exam: abc

Sorry, your input must be an integer. Please try again. Please enter in the score for the first exam: 97

Please enter in the score for the second exam: 65

Please enter in the score for the final exam: 85

Enter the score for a homework assignment: abc

Sorry, your input must be an integer. Please try again. Enter the score for a homework assignment: 200

Sorry, your input must be between 0 and 100. Please try again. Enter the score for a homework assignment: 99

Enter the score for a homework assignment: 65

Enter the score for a homework assignment: 78

Enter the score for a homework assignment: 80

Enter the score for a homework assignment: -1

The median homework score was 79

The total points earned was 326

The letter calculated letter grade is B

As a reminder, you need to place all input at once into the input window in Zylabs. For the example above, the input is:

abc

97

65

85

abc

200

99

65

78

80

-1