pdayakar reddy

Greenhorn

Posts: 5

posted 6 years ago

getting 1900 is a leap year but 1900 is not a leap year

leap year: 1900

leap year: 1904

leap year: 1908

leap year: 1912

leap year: 1916

leap year: 1920

leap year: 1924

leap year: 1928

leap year: 1932

leap year: 1936

leap year: 1940

leap year: 1944

leap year: 1948

leap year: 1952

leap year: 1956

leap year: 1960

leap year: 1964

leap year: 1968

leap year: 1972

leap year: 1976

leap year: 1980

leap year: 1984

leap year: 1988

leap year: 1992

leap year: 1996

leap year: 2000

leap year: 2004

leap year: 2008

Number of leap years:28

getting 1900 is a leap year but 1900 is not a leap year

leap year: 1900

leap year: 1904

leap year: 1908

leap year: 1912

leap year: 1916

leap year: 1920

leap year: 1924

leap year: 1928

leap year: 1932

leap year: 1936

leap year: 1940

leap year: 1944

leap year: 1948

leap year: 1952

leap year: 1956

leap year: 1960

leap year: 1964

leap year: 1968

leap year: 1972

leap year: 1976

leap year: 1980

leap year: 1984

leap year: 1988

leap year: 1992

leap year: 1996

leap year: 2000

leap year: 2004

leap year: 2008

Number of leap years:28

posted 6 years ago

Please use () to surround the conditions which you are evaluating together. You could try-

And please UseAMeaningfulSubjectLine and UseCodeTags for posting the source code.

`((l==0)||(j==0))&&(k!=0)`And please UseAMeaningfulSubjectLine and UseCodeTags for posting the source code.

Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook

pdayakar reddy

Greenhorn

Posts: 5

posted 6 years ago

Thanks alot

Mohamed Sanaulla wrote:Please use () to surround the conditions which you are evaluating together. You could try-((l==0)||(j==0))&&(k!=0)

And please UseAMeaningfulSubjectLine and UseCodeTags for posting the source code.

Thanks alot

Stephan van Hulst

Saloon Keeper

Posts: 7992

143

posted 6 years ago

Actually, this is wrong as well, as this would not list 1600 as a leap year. The correct expression is:

*The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.*

Eswar Nec

Ranch Hand

Posts: 105

posted 6 years ago

Hi,

Try understand to leap year concept.

If any 4 digit number end with two zero, that number exactly divide by 4. ( For example 1900%4 == 0 )

So you not consider (1900) is a leap year.

How to identify

If you see any 4 digit number end with two zero , you do the following steps.

Step 1 : Remove last two digit, then get only 19.

Step 2 : divide by 4 (19%4 == 3)

So 1900 is not a leap year.

Step 1 : Remove last two digit, then get 16

Step 2: Divide by 4 (16%4 == 0)

so 1600 is leap year.

I hope its useful for you.

pdayakar reddy wrote:

getting 1900 is a leap year but 1900 is not a leap year

[/color]

Hi,

Try understand to leap year concept.

If any 4 digit number end with two zero, that number exactly divide by 4. ( For example 1900%4 == 0 )

So you not consider (1900) is a leap year.

How to identify

**leap**and

**non-leap**year with

**last two digit is zero**

If you see any 4 digit number end with two zero , you do the following steps.

**Take, non leap year 1900.**

Step 1 : Remove last two digit, then get only 19.

Step 2 : divide by 4 (19%4 == 3)

So 1900 is not a leap year.

**Take a leap year : 1600**

Step 1 : Remove last two digit, then get 16

Step 2: Divide by 4 (16%4 == 0)

so 1600 is leap year.

I hope its useful for you.

Wake up! Don't let your smile be snatched away by anybody!

Regards, Eswar

posted 6 years ago

That's what the % 400 is for.

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6

How To Ask Questions How To Answer Questions

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |