java date - testmy.net resource / tool
Home
Welcome, Guest. Please login or register.
Did you miss your activation email?

 



donations help testmy.net pay for the very high cost to run the site. Any amount is greatly appreciated.
Click to read why...

  spcr
    
News : uglystupid2 Don't look stupid, make sure you keep up-to-date with our rules, please read rules, click here  police August 28, 2008, 11:20:25 PM
testmy.net Broadband  |  Main Forum  |  HELP!  |  Programming and Website Help  |  Topic: java date Advanced search
  0 Members and 1 Guest are viewing this topic. « previous next »
Pages 1 Go Down
Author
Topic: java date  (Read 899 times)
jamaicarocks
TMN Friend
*
Offline Offline

Posts: 297


There's no place like 127.0.0.1 .


View Profile WWW
« on: October 06, 2007, 09:51:41 PM »

good day,

                I am designing a program in Java and want users to enter their birth month, entering a number between 1-12, which represents Jan to  Dec ..........then prints out the Month which corresponds to the number they entered.

The problem I'm having is Java's month starts at January corresponding to number 0.
How could I change this, or see instructions to change this.

Thank you
Logged

Image and video hosting by TinyPic
fr0stbound
Expert
*
Offline Offline

Posts: 1292



View Profile
« Reply #1 on: October 07, 2007, 01:50:48 AM »

to put it crudely, store the user input in a variable. subtract 1 from the value, then use the result to process output.

therefore, if user inputs 1, store to variable a, then subtract 1. that will make it as though the user input(inputted? i don't know the past tense) 0. and so on for other numbers.

sorry if it was hard to understand, i don't know how to program with java(yet). do you know c? if you want, i'll give you a sample source code.

also, a tip, since this is the hardest to do at beginner level programming. make sure you make an error catching sort of module, in case the user inputs a wrong value. in your case, it will be inputting a month higher than 12. my teacher taught me this the hard way. a simple nested if-then statement will do the job.
Logged


Quote from:  Jimi Hendrix
When the power of love overcomes the love of power, the world will know peace.

If uppercase letters don't exist, what will you think if you see someone says "I helped my Uncle Jack off a horse"
jamaicarocks
TMN Friend
*
Offline Offline

Posts: 297


There's no place like 127.0.0.1 .


View Profile WWW
« Reply #2 on: October 07, 2007, 02:44:29 AM »

Thanks alot,will try your suggestion, a sample code would have helped a lot.I will use whats known as a Toolbox in Java to kinda restrict what the users can enter.

thanks so far
Logged

Image and video hosting by TinyPic
Print  Pages 1 Go Up
testmy.net Broadband  |  Main Forum  |  HELP!  |  Programming and Website Help  |  Topic: java date « previous next »
Jump to:  

    
testmy.net's forum is proudly Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Bookmark: Del.icio.us    StumbleUpon
 
 

 

© 1999-2008 testmy.net - Contact - Legal - Facts & FAQs
Page Loading Stats: This forum Page created in 0.086 seconds with 29 queries.