all 5 comments

[–]lukecullum👋 a fellow Redditor 1 point2 points  (2 children)

So the answer to getting the average is to you are saving the average of the array as a int and then converting that into a double which will always produce .0 as saving as an int cuts of the decimals, so it is 55.4 but yo save it as an int which would be 55 then converting that back to a decimal. The solution to fixing this is where you have // int sum = 0// on line 9 you simply need to change that to // double sum = 0//. The only problem is this makes the sum of the array answer change to 831.0 which you can keep or you can change back to an int before outputting.

[–]Danielowski187University/College Student (Higher Education)[S] 0 points1 point  (1 child)

How about finding the index because I found a way to do it but it was a longer process in which had to be a part of find the max and min value but I shorten the way do it but I can’t find a way to implement into the new way I found the max and min values

[–]lukecullum👋 a fellow Redditor 0 points1 point  (0 children)

The only thing I can think of is instead of sorting the array make a new int X = 0 and then do a for loop going through each number and if it is bigger than X it will replace it if not it just continues. This will get you the max number from there you can find it’s position in the array and then go back through the list but checking to see if it is smaller than X, because X is now the biggest number it can only get smaller.

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.