Jump to content

Recommended Posts

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

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Speed Test Version 15.9
© 2019 TestMy Net LLC - TestMy.net - Terms & Privacy