Help with Homework

I need assistance with a homework problem. The home work problem is as follows: This program is an application of finding largest/smallest value. In some sports requiring judges to give scores, such as diving and gymnastics, typically the highest score and lowest score are excluded in calculating the athlete’s average score. Write a program to do the following. Ask the user to enter 5 scores given by judges. Find and display the largest score and lowest score. Then calculate and display the athlete’s average score with the largest score and lowest score excluded. Be smart in how to exclude the largest score and lowest score once they are found. It can be done easily if you do it in a smart way. I have included what I have done with the code so far. I am not sure how I can go about doing the average.

#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
// Declare variables
double a = 0.0;
double b = 0.0;
double c = 0.0;
double d = 0.0;
double e = 0.0;
double highest = 0.0;
double lowest = 0.0;


// Request input
cout << "Please enter five scores." << endl;
cout << "First score: ";
cin >> a;
cout << "Second score: ";
cin >> b;
cout << "Third score: ";
cin >> c;
cout << "Fourth score:";
cin >> d;
cout << "Fifth score:";
cin >> e;

// Determine the highest and lowest score and display an average;
highest = a;
if (b > highest)
{
highest = b;
}
if (c > highest)
{
highest = c;
}
if (d > highest)
{
highest = d;
}
if (e > highest)
{
highest = e;
}
lowest = a;
if (b < lowest)
{
lowest = b;
}
if (c < lowest)
{
lowest = c;
}
if (d < lowest)
{
lowest = d;
}
if (e < lowest)
{
lowest = e;
}
cout << "Largest number: " << highest << endl;
cout << "Lowest number:" <<lowest << endl;
system("pause");
return 0;
}

Last edited on
Post your code :o we'll guide you, not write for you (hopefuly)
Topic archived. No new replies allowed.