Answer to Question #182388 in C++ for john gullardo

Question #182388

Your goal is to create a program that will determine the average score for an


athlete in a competition. There are 10 judges who each award a score between 0


and 10. The lowest and highest scores are thrown out, and the athlete’s score is


the average of the eight remaining scores.


You need to create a scorecard file in a text editor or type it into onlineGDB. The


scorecard should have the first and the last name of the athlete on the first line


and 10 space-separated numbers between 0 and 10 on the second line. The


numbers should have at most 1 digit after the decimal point.


An array to hold the scores from all judges.


Example Input File:


Mirabella Jones


7.5 8.8 7 8.1 8 9.8 9.3 8.9 9.1 9


Example Output:


Mirabella Jones's results:


7.5, 8.8, 7.0, 8.1, 8.0, 9.8, 9.3, 8.9, 9.1, 9.0


The highest score of 9.8 and the lowest score of 7.0 were


dropped


The average score is 8.59



1
Expert's answer
2021-04-16T16:38:33-0400
#include <iostream>
#include <vector>
#include <string>
using namespace std;


int main()
{
    vector<double> marks;
    string name, sername;
    cout << "Enter Name ";
    cin>> name;
    cout << "Enter sername ";
    cin>> sername;
    cout << "Enter 10 marks";
    double m;
    for (int i=0; i< 10; ++i)
    {
        cin>>m;
        marks.push_back(m);
    }
    
    cout << name << " " <<sername << " results:" << endl;
    double max=0, min=10, sum=0;
    for (int i=0; i<10; ++i)
        if (max<marks[i])
            max=marks[i];
    for (int i=0; i<10; ++i)
        if (min>marks[i])
            min=marks[i];
    for (int i=0; i<10; ++i)
        cout << marks[i]<<" ";
    
    cout << "The highest score of "<<max<<" and the lowest score of "<< min<<" were dropped"<<endl;
    for (int i=0; i<10; ++i)
        sum+=marks[i];
    sum=(sum-max-min)/8;
    cout << "The average score is " << sum;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS