Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 299,949 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,798 people online right now. Registration is fast and FREE... Join Now!




dates do not print

 

dates do not print

Rating  5
Geez

5 May, 2008 - 11:17 AM
Post #1

New D.I.C Head
*

Joined: 5 May, 2008
Posts: 23


My Contributions
Hi all,

I'm just starting out with java and ran into this problem- 1709 does not print- I also tried with other dates like 1963 and that date doesn't print an outcome either.

CODE
public class validate {

    public static void isLeapYear(int year){
        String yes = " Is a Leap Year";
        String no = " Is not a Leap Year";
        
        if((year%100 == 0)  && (year%400 != 0)){
            
          System.out.println(+year +no);
        }
        else if(year%4 == 0){
            System.out.println(+year +yes);
        }
    
        }
    

    public static void main(String[] args) {
        
        isLeapYear(1900);
        isLeapYear(2000);
        isLeapYear(1968);
        isLeapYear(1700);
        isLeapYear(1963);
        isLeapYear(1709);
        
    }
        
}

    


]

User is offlineProfile CardPM
+Quote Post


pbl

RE: Dates Do Not Print

5 May, 2008 - 11:40 AM
Post #2

Java Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 9,518



Thanked: 1120 times
Dream Kudos: 450
My Contributions
You are only printing NO for the one that are a multiple of 100 and not 400

is 1963 % 100 == 0 No so you didn't print it in your first println
is 1963 % 4 == 0 No so you didn't print it in your second println

I guess that would work:

CODE

if((year%100 == 0)  && (year%400 != 0)){
            
          System.out.println(+year +no);
        }
        else if(year%4 == 0){
            System.out.println(+year +yes);
        }
        else
            System.out.println(year + no);


User is offlineProfile CardPM
+Quote Post

Geez

RE: Dates Do Not Print

5 May, 2008 - 11:50 AM
Post #3

New D.I.C Head
*

Joined: 5 May, 2008
Posts: 23


My Contributions
Yeps that was it thanks I just figured it out by myself. that was a really dumb mistake on my part. thnx for answering though, appreciate it.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/6/09 04:46PM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month