Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
4
Indexable
Never
#include <iostream>
#include <iomanip>
using namespace std;

float mark, biggest, smallest, total, average;
int judges, counter;
int main ()
{
    cout << "Enter the number of judges: ";
    cin >> judges;
    while (judges < 4 || judges > 8){
        cout << "Invalid. Please enter a number between 4 to 8";
        cin >> judges;
    }

/* Mark for the judges */
    biggest = 0;
    smallest = 10;
    total = 0.0;
    average = 0.0;
    for (counter = 0; counter < judges; counter++){
        cout << "Enter mark: ";
        cin >> mark;
        while (mark <= 0.0 || mark > 10.0){ /*For when mark goes past 10.0*/
            cout << "Invalid. Enter mark again (0.0 to 10.0): ";
            cin >> mark;
        }
        if (biggest < mark){ /*Identifying the largest mark*/
            biggest = mark;
        }
        if (smallest > mark){ /*Identifying the smallest mark*/
            smallest = mark;
        }
        total = (total + mark);
    }
        total = total - (biggest + smallest); /*Excluding the min and max marks*/
        average = total/(judges - 2);

        cout << setprecision(2) << "Final mark: " << average << endl; /*2 decimal places*/
}