# Need to look for only 5 and 10's

Printable View

• 11-11-2009, 06:38 AM
PCarlson
Need to look for only 5 and 10's
I'm writing a program that gives awards based on years served, given the staff has been employed for 5, 10, 15, 20, etc. years they get a plaque with the number of years employed. anyone got any hints or tips on a method I could write which would compare/decipher whether or not the number is a 5's or 10's number.
• 11-11-2009, 06:43 AM
Fubarable
Use the mod operator (%) to see if an int is divisible by 5. If so, then number % 5 will equal 0.

Much luck and welcome to the forum!
• 11-11-2009, 06:45 AM
PCarlson
thanks much :)
• 11-13-2009, 08:11 AM
aaroncarpet
if ((yearsemployed % 5 == 0 )|| (yearsemployed % 10 == 0))
write plaque for yearsemployed
• 11-14-2009, 08:19 PM
Arnold
Quote:

Originally Posted by aaroncarpet
if ((yearsemployed % 5 == 0 )|| (yearsemployed % 10 == 0))
write plaque for yearsemployed

Why? what's the "(yearsemployed % 10 == 0)" part good for? If the first condition of an or operator is true, then it won't even evaluate the second.

BTW: Sometimes it seems the beginners and advance sections switch sides.
• 11-14-2009, 08:52 PM
aaroncarpet
no need for remainder 10
I realized the same thing as I was going to bed. the problem was I was over focused on his title 5's and tens. I am working on a huge prime number project. So I was going to sleep thinking duh? 10 is divisible by five. I am not a senior programmer but I do have alot of experience with j2se. so maybe I am a beginner. I am new to this forum stuff and I need to learn to think before I type. My apologies

what about the employees with 6-9yrs 11-14 etc maybe they should have plaques 5+yrs 10+...I think the people with in between years long term service to the company will feel spited.....but i don't work there