programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

# New average with lowest score dropped in array

Greenhorn
Posts: 15
• Number of slices to send:
Optional 'thank-you' note:

Our first exercise is to find the total average of test scores in an array and that part was easy. The second exercise is to then print a new average with the lowest score dropped. Our prof specifically does not want us to use the getLowestScore method. What am I doing wrong?

if (scores [count] < lowest)

double newAverage = 0;
double newSum = 0;
double newTotal = 0;
lowest = scores[count];
newTotal = total-lowest;
newSum
newAverage = (double) newSum/newTotal;

System.out.println("The lowest score in the array is " + lowest);
System.out.println("The new average with lowest grade dropped is " + newAverage);

Sheriff
Posts: 22701
129
• Number of slices to send:
Optional 'thank-you' note:
How about calculating the sum of all elements, then subtracting the minimum value? You then have the sum of all elements except the lowest value. If you divide this number by the number of elements - 1 you get the average with the lowest value dropped. Well, one occurrence of the lowest value anyway.

You are subtracting the minimum value at that time, which may or may not be the overall minimum. If it isn't you need to add it again, but you don't.

Crea Smith
Greenhorn
Posts: 15
• Number of slices to send:
Optional 'thank-you' note:
I understand the process. I just have no idea what java syntax to use to code it. I've tried everything I know for 7 hours and nothing.

Rob Spoor
Sheriff
Posts: 22701
129
• Number of slices to send:
Optional 'thank-you' note:
Well, what do you have so far? Show us the code: the declarations, initializations, loop, etc.

Crea Smith
Greenhorn
Posts: 15
• Number of slices to send:
Optional 'thank-you' note:
I got it all figured out now.

 Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad. the value of filler advertising in 2021 https://coderanch.com/t/730886/filler-advertising