• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding to the print out values

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


My problem is where do I start or add the following code to be added?

I only want to use 1 array and may be or should I try a catch block? any help is appreciated in advance...
The number or numbers that were picked least frequently.
The average number of times that all of the numbers were picked. For example, the average might have been 210 times.
The number or numbers that were picked the average number of times.
The number or numbers that were picked most frequently
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First: Welcome to javaRanch, conner.

conner Statham wrote:I only want to use 1 array


Why? Have you been told that you must? If not, don't start putting constraints on yourself before you even start.

and may be or should I try a catch block?


Lesson 2: Don't guess. try...catch blocks are used for a very specific reason; so before you start coding, read up on WHY you might need one.

The number or numbers that were picked least frequently.
The average number of times that all of the numbers were picked. For example, the average might have been 210 times.
The number or numbers that were picked the average number of times.
The number or numbers that were picked most frequently


Lesson 3: StopCoding (←click) - or rather, in your case, don't start coding until you know what you need to do.

One thing I can tell you is that, in general, the more methods your class has, the better it will be. You've been given 4 tasks to complete, so think about writing 4 methods (at the very least) to do them.

And before you write one line of code for them: THINK.

Take your first task: "[Print out] the number or numbers that were picked least frequently."

What exactly do you need to do to find out the "least frequent number or numbers"? A good tip is to write out a description as though you were describing it to a child who has no knowledge of Java.
Also: if you want "numbers", how many do you want? The bottom 3...or 5...or 10? You need to be precise.

And do that for all 4 tasks before you write a line of code.

HIH

Winston

PS: You might be interested in reading the WhereDoIStart page.
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic