• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

New to Netbeans - Project Question

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
author & internet detective
Posts: 42148
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Nc Marie
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic