Forums Register Login
New to Netbeans - Project Question
Hi - I'm working on a project to allow a user to enter test scores one at a time then click the Enter Score button. After each entered score, the application returns the number of scores (count), Average Score and Best score. The program accumulates each entry and calculates values on all entries until the clear button is clicked. The code I have so far is pasted below - it's rough - I apologize - I'm brand new at this! Thanks for your help.

Welcome to CodeRanch! I've edited your post to add [ code ] tags which makes the code easier to read.

I don't see what the question is though. Can you restate it?
Thank you for your response! My question is I am looking for the code to actually calculate and return the values of best score, average score and number of scores entered each time the user clicks the "Enter Score" button. The code below is referencing an array but my type is double. I think I need to use an array list but not sure how to code that. Hope that makes sense! Thanks!
Forget about the GUI for a moment and work only on the calculateScores method. You can test this in a separate class.

Whenever the calculateScore is called with a testScore, you first need to add this testScore to your existing score(s) (which might have been added earlier). You have declared an double array, but, I don't see anywhere the testScore being set in the array. As you can see, you will have to dynamically allocate the size of array every time a score is added and also copy over the earlier values. Like you have said, this is what ArrayList does.
For all primitive types, Java has a corresponding class which are called wrapper classes. So, in this case, you should use an array list which can take instances of Double.

I think I have given you an outline and enough info to start with.

This thread has been viewed 1283 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 25, 2018 01:22:31.