New course! Every coder should learn Generative AI!
Try a free lesson+ 2
http://code.sololearn.com/ceGz03Ee0wHp
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double sum, min, max, i;
unsigned int count;
sum = 0;
min = 10000;
max = 0;
i = 0;
count = 0;
cout << "Please enter the grades (stop code: -1)" << endl;
while (i >= 0) {
cin >> i;
if (i >= 0) {
cout << i << " ";
count++;
sum += i;
if (i < min) {
min = i;
}
if (i > max) {
max = i;
}
}
}
cout << endl;
if (count > 0) {
cout << "Regular average: " << round(10*sum/count)/10.0 << endl;
}
if (count > 1) {
cout << "Average with lowest dropped: " << round(10*(sum-min)/(count-1))/10.0 << endl;
}
if (count > 0) {
cout << "Average where highest counts twice: " << round(10*(sum+max)/(count+1))/10.0 << endl;
}
return 0;
}