![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
% 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? |
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4
![]() |
Quote:
, 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 |
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
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(); } |
|
|
|
|
|
#4 |
|
Professional Programmer
|
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 ! |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
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.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|