Calculating average without highest and lowest values in an array
By : user3734521
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I don't understand why you need to remove the high and low value from the array to get the average? The average should be the sum of all values divided by the total number of values: code :
double sum = 0;
for (int index=0; index < contestantOne.length; index++)
{
//If you really need to remove highest and lowest value
if (contestantOne[index] != contestantOneLow && contestantOne[index] != contestantOneHigh)
sum += contestantOne[i];
}
double avg = sum / (double)(contestantOne.length  2);

Find highest,lowest and average in a loop
By : cicero
Date : March 29 2020, 07:55 AM
may help you . Your highest and lowest variables both start at 0. So if your numbers are all negative, you'll get a highest of 0, incorrectly. If your numbers are all positive, you'll get a lowest of 0, incorrectly. Just start off with highest = Integer.MIN_VALUE and lowest = Integer.MAX_VALUE and then the first iteration will end up with the correct highest and lowest value.

Sort a dictionary by average values highest to lowest
By : Michel
Date : March 29 2020, 07:55 AM
this one helps. Dictionaries cannot be sorted. Once you have added the scores to your dictionary, you then need to take them out of the dictionary again to sort them. Try something like: code :
sorted([(k,sum(v)/len(v)) for k,v in player_scores.items()], key=lambda x: x[1], reverse=True)

How do i get the Average, Highest and Lowest of values from a listbox and then display it on a textbox
By : Tycho
Date : March 29 2020, 07:55 AM
To fix the issue you can do I have the following code, how can I get the values from the items in the listbox and get my program to find the average, highest and lowest of the values. I currently have the following textboxes (averageTextbox, highestTextbox, lowestTextbox) and I wish to display the values accordingly into the textboxes. in Advance! code :
double lowest = Double.MaxValue;
double highest = Double.MinValue;
double average = 0;
while ((line = file.ReadLine()) != null)
{
displayListBox.Items.Add(line);
var dbl = Convert.ToDouble(line);
if (dbl > highest)
highest = dbl;
if (dbl < lowest)
lowest = dbl;
dblAdd += dbl;
counter++;
}
if (counter > 0)
{
average = dblAdd / (double)counter;
}
else
{
highest = lowest = 0;
}

How do I get inputs from a user and find the highest, lowest, and average of them?
By : Kay Haigh
Date : March 29 2020, 07:55 AM

