Question: This is C++ modify the Test Scores program from chapter 6 so it uses some of the algorithms presented in this chapter. When youre done,

This is C++

modify the Test Scores program from chapter 6 so it uses some of the algorithms presented in this chapter. When youre done, a test run should look like this:

This is C++ modify the Test Scores program from chapter 6 soThis program is based on exercise 11-1in the textbook: it uses some of the algorithms presented in this chapter. When youre

#include

#include

#include

using namespace std;

int main()

{

cout

cout

vectorint> scores;

int score = 0;

while (score != -1) {

cout

cin >> score;

if (cin.fail()) {

cin.clear(); // clear error bits

cin.ignore(1000, ' '); // discard input up to end of line

cout

}

else if (score > 100) {

cout

}

else if (score

cout

}

else if (score > -1) { // valid score add to vector

scores.push_back(score);

}

}

if (scores.empty()) { // vector is empty

cout

}

else { // vector contains scores

// calculate total of all scores

int total = 0;

for (int score : scores) {

total += score;

}

// get the count and calculate the average

auto score_count = scores.size();

double average = static_castdouble>(total) / score_count;

average = round(average * 10) / 10;

// display the score count, total, and average

cout

}

}

  1. Modify the program so it sorts the scores in descending sequence. To do that, use the sort() algorithm with a function that specifies the sort order.

  2. Add code that displays the sorted scores as shown above. To do that, use the for_each() algorithm with a function that displays a score.

  3. Add code that gets and displays the highest and lowest scores.

  4. Add code that gets the number of scores that are equal to 100. Then, display that number.

  5. Modify the code that gets the total of the scores so it uses the accumulate() algorithm instead of a range-based for loop

  6. Modify the code to alert the user is less than 5 scores are input.

  7. Modify the code to only consider the highest 4 scores.

The Test Scores program Enter test scores from 0 to 100. To end the program, enter -1. Only the highest four scores are counted. Enter score: 100 Enter score: -1 Less than 5 scores entered ***Program Rerun***| The Test Scores program Enter test scores from 0 to 100. To end the program, enter -1. Only the highest four scores are counted. Enter score: 100 Enter score: 99 Enter score: 98 Enter score: 97 Enter score: 96 Enter score: 95 Enter score: 94 Enter score: -1 Highest four scores: 100 99 98 97 Highest score: 100 Lowest score: 97 This student has 1 perfect score (s)! Score count: 4 Score total: 394 Average score: 98.5 O insin.cpp - Edited marcop Frano 1 include include > scorci if (cin.faill ein.elser: cin.sgncrs 1638, "in') discard input da to end of line cout 180) { cout -1){ // valid score Scores.push back (ACOTA) and to vector 17 (Scores, empty()) { cout ss -inko scorcs cntcredin."; vector is arpty // what contains score alget // calculate total of 511 scores int total = 0; for (int score : scere! [ tatal - ACOTA // cat the count and calculate the HURTIH auto score count - scores.size(): double average = static cast doublestotal) / score_count; average = round average * 10) / 16; // cisplay the scorc count, total, and average cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!