I have to write a program for homework that asks for contestant scores, then outputs the total after the lowest and highest number are deleted. This is what I have so far. I can't use a sort since we haven't covered that yet and I'm not sure exactly how to subtract the lowest and highest number without sorting. Any help is much appreciated.

Thanks!

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

int main()
{
int counter;
double sum;
double data ;

cout<<"Enter data: ";

for (counter = 0; counter < 8; counter++)
data[counter] = 0.0;
for (counter = 0; counter < 8; counter++)
cin>>data[counter];
sum = 0;
for (counter = 0; counter < 8; counter++)
sum = sum + data[counter];
cout<<endl;

cout<<"Total points =  "<<sum<<endl;

return 0;
}``````

I think you can do the following:

Define MAX as the maximum of the scores. First set it as equal to the first element of the array of scores. Then compare successively MAX with the elements of the array. Set MAX as equal to the particular element if MAX is less than the element; otherwise, proceed to compare MAX with the next element.

The minimum MIN of the scores can likewise be obtained.

Finally, of course, just substract MAX and MIN from the sum.

Is this what you mean?

while (max > 0.0 || max <= 10.0)

No, I mean insert the following code into yours after the data are entered:

MAX = MIN = data;
for (counter = 1; counter < 8; counter++)
{
if (data[counter]>MAX) MAX = data[counter];
if (data[counter]<MIN) MIN = data[counter];
}

Is this what you mean?

while (max > 0.0 || max <= 10.0)

Thank you so much! This worked beautifully.

I'm fairly new to this stuff, so I usually ask a lot of questions if I'm not quite sure about something.

Hello Kitty,

can you help with with my array question? I need to store the users input into an array, then sum the numbers and then print them out in reverse.

Hello Kitty,

can you help with with my array question? I need to store the users input into an array, then sum the numbers and then print them out in reverse.

Judging by the date this thread was initiated, my guess is that KittyGirl became a KittyWoman, met a CatMan, GotMarried, had maybe a couple of KittyKids and is long gone by now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.