Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Zodiac Signs

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys! I have a program here that generates the zodiac sign and chinese zodiac, but there is a problem. When you enter a month - 13 or higher it generates a result.
What should I do to fix this problem?
Here are my codes:


 
Marshal
Posts: 70349
283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try entering a date, eg 13/14/2015 and getting it printed out. You will probably get 14th Jan 2016. What is probably happening is that the Calendar object is accepting 13 as one month beyond December. Read the Calendar documentation about “leniency”; that may help sort out your problem.
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vino Free wrote:What shoul I do to fix this problem?


I think Campbell's basically covered it.

However: Are you familiar with enums? Because both of your "zodiac" types would be a great place to use them.

Winston
 
Vino Free
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Campbell!
Your suggestion is very helpful.
 
Campbell Ritchie
Marshal
Posts: 70349
283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You’re welcome
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic