• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generate rectangle width from user input

 
Alex Morph
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a program where the user enters day number + rainfall. At the moment it outputs an array displaying - "1 : 9cm, 2: 11cm" etc. I need to implement something that resembles a bar chart, so I need an output of "1 : *insert rectangle of 9cm* 9cm". At the moment I have this:


I dunno how to go about retrieving the user input and making it the rectangle's width!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are on the right track!
In pseudo code:
1) Accept user input
2) Use this input to draw your graph

To get an idea, check out these two
https://www.coderanch.com/how-to/java/PlotTest
https://www.coderanch.com/how-to/java/PlotSineCurve

In case this is not an academic exercise or you want more once you achieve your own custom painting, check out http://www.jfree.org/jfreechart/
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!