Development Java Newbie :: Thermometer

Discussion in 'Software' started by Zach, 27 Nov 2005.

  1. Zach

    Zach What's a Dremel?

    Joined:
    29 Jul 2005
    Posts:
    138
    Likes Received:
    0
    im trying to help a friend with some coursework, but i dont know where to begin, im familiar with principles of programming did 1 yr of c++ but never got *into* it.

    he has to "Write a program that will read a single number as a command line argument, and display this as a graphical thermometer"

    where do we begin, how much effort would we need to exert, alot a little, is it piss easy any similar source code out there? any helpful super skilld individuals out there with a spare 5 mins ;)

    thnx alot for any replies.
     
  2. JazzXP

    JazzXP Eh! Steve

    Joined:
    30 Apr 2002
    Posts:
    1,669
    Likes Received:
    13
    I'm not doing it for you, but here's a couple of hints.

    your main method has the arguments (public static void main(String args[])) so the first value in the args array will be the number passed to you. To turn that into an int use Integer.parseInt (don't forget to catch the exceptions).

    As for the graphical bit, create a new Frame (if using AWT, JFrame if using Swing), and add your thermometer to that.
     
  3. 731|\|37

    731|\|37 ESD Engineer in Training

    Joined:
    5 Sep 2004
    Posts:
    1,047
    Likes Received:
    0
    not going to give you any code because I dont have THAT much time. but sure I can lay it out.


    Set up two arrays of 10 Strings to be your "mercury", and a label

    set up your command input

    run your recieved string through a var conversion method (just to an int probobly)
    and make sure you put it in try blocks (to catch invalid string content)

    round out the number to the nearest 10

    youl have to invert your results as your writing from the top of the display. but then just print your scale marker followed by a "mercury" if necesary.
     
  4. Zach

    Zach What's a Dremel?

    Joined:
    29 Jul 2005
    Posts:
    138
    Likes Received:
    0
    thnx for the help, i got on some online tutorials too it seems like it should be easy enough. :D
     
  5. 1e8o

    1e8o What's a Dremel?

    Joined:
    13 Oct 2005
    Posts:
    272
    Likes Received:
    0

    where did you find it?
     
  6. 731|\|37

    731|\|37 ESD Engineer in Training

    Joined:
    5 Sep 2004
    Posts:
    1,047
    Likes Received:
    0
    hes asking for basic java help and array manipulation. its not like this is something special. "java tutorial" would probobly get you all you need to know
     
  7. Fod

    Fod what is the cheesecake?

    Joined:
    26 Aug 2004
    Posts:
    5,802
    Likes Received:
    133
    i always found that www.mindprod.com had some great java resources. that and the SUN javadoc and you're golden.
     
  8. 731|\|37

    731|\|37 ESD Engineer in Training

    Joined:
    5 Sep 2004
    Posts:
    1,047
    Likes Received:
    0
    yes... after I took my first java course I had to find a way to download that resource... ^_^
     

Share This Page