• 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

so i am stuck here trying to create a historgram and i did this a while ago but different

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its been a long time for me coding wise and i seem to be drawing a blank here
this is what i want to happen

however this is what is happening

here is my code


 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted here: http://www.java-forums.org/new-java/96091-stuck-trying-take-old-historgram-progam-changing-around.html
 
Marshal
Posts: 79072
376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take NR's point. People here and in the other forum need to know if you post the same question on two websites. Also work out how the code tags work; they are similar to the other forum. I corrected your tags this time. I also added code tags round your desired output because the tags also improve the appearance of outputs. Do you really want the output double‑spaced?

I am afraid I don't like your solution because:-
  • 1: You have too much code in the main method, and you are actually writing procedural code rather than object code.
  • 2: Your loop in line 21 destroys information. If you get that loop to run, you will convert your array to {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}.
  • Please look very carefully at the loop in line 16 and work out how many times it will run.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic