Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 4th, 2005, 8:45 PM   #1
dark_omen
Hobbyist Programmer
 
Join Date: Dec 2004
Posts: 125
Rep Power: 4 dark_omen is on a distinguished road
Send a message via AIM to dark_omen
% problem

Ok so I made this program that would filter out the dates that weren't evenly divisble by 15, so I used:

if(year % 15 == 0){}

but it didn't filter them out. Is there something wrong, or is this just the wrong thing to use?
dark_omen is offline   Reply With Quote
Old Oct 4th, 2005, 9:14 PM   #2
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
Quote:
Originally Posted by dark_omen
Ok so I made this program that would filter out the dates that weren't evenly divisble by 15, so I used:

if(year % 15 == 0){}

but it didn't filter them out. Is there something wrong, or is this just the wrong thing to use?
maybe you want the day, and not the year?? If the dates are all in 2005, none will fit. I think 2010 is the next year evenly divisible by 15 , and the last one was 1995.

Just a wild guess. How does the rest of the code in the if-block look?
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Oct 4th, 2005, 9:50 PM   #3
dark_omen
Hobbyist Programmer
 
Join Date: Dec 2004
Posts: 125
Rep Power: 4 dark_omen is on a distinguished road
Send a message via AIM to dark_omen
No i want the year, it goes from 1628 to 2005 (every year in between too).

This is the rest of the if statement:
if((year % 15 == 0) || (year % 100 == 0) || (year == 2005)){ System.out.println(); }
dark_omen is offline   Reply With Quote
Old Oct 4th, 2005, 10:58 PM   #4
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 406
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
class year{
	public static void main(String [] args){
		
		for(int i = 0 ; i <= 2005 ; i++)
			if((i%15 == 0) || (i%100 == 0) || (i == 2005) ){
				System.out.println(i);
			}
	}
}

This works , so there has to be something else wrong with your code.
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Oct 4th, 2005, 11:07 PM   #5
dark_omen
Hobbyist Programmer
 
Join Date: Dec 2004
Posts: 125
Rep Power: 4 dark_omen is on a distinguished road
Send a message via AIM to dark_omen
OK it works, I found that I was incrementing it twice, and there wasn't anything wrong with the if statement. Thanks for the help though.
dark_omen is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC