Results 1 to 6 of 6
  1. #1
    PCarlson is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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!

  3. #3
    PCarlson is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default

    thanks much :)

  4. #4
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    if ((yearsemployed % 5 == 0 )|| (yearsemployed % 10 == 0))
    write plaque for yearsemployed

  5. #5
    Arnold is offline Member
    Join Date
    Oct 2009
    Location
    Rotterdam
    Posts
    52
    Rep Power
    0

    Exclamation

    Quote Originally Posted by aaroncarpet View Post
    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.

  6. #6
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default 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
    Last edited by aaroncarpet; 11-14-2009 at 07:55 PM. Reason: other thoughts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •