leap year logic

Ads
 

leap year logic

View Answers

August 12, 2009 at 3:29 PM

Hi Friend,

Please visit the following link:

http://www.roseindia.net/java/beginners/Leapyear.shtml

Thanks

January 21, 2012 at 2:22 PM

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LeapYrDemo {
public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
             System.out.println("Enter num");
             int yr = br.read();

int num = yr;
if(num/100== 0){
    if(num/400==0){
        System.out.println("Leap year");
        }
    else
        System.out.println("not leap yr");
}
else if(num/4==0){
    System.out.println("leap yr");
}
else
    System.out.println("Not a leap yr");

} catch (IOException ex) {
            Logger.getLogger(LeapYrDemo.class.getName()).log(Level.SEVERE, null, ex);
        }
}

}


OutPut:

Enter num
2012
Leap year
BUILD SUCCESSFUL (total time: 4 seconds)

January 21, 2012 at 2:24 PM

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.logging.Level;

import java.util.logging.Logger;

public class LeapYrDemo {

public static void main(String[] args) {

        try {

            BufferedReader br = new BufferedReader(new 

            InputStreamReader(System.in));

 System.out.println("Enter num");

             int yr = br.read();



int num = yr;

if(num/100== 0){

    if(num/400==0){

        System.out.println("Leap year");

        }

    else

        System.out.println("not leap yr");

}

else if(num/4==0){

    System.out.println("leap yr");

}

else

    System.out.println("Not a leap yr");



} catch (IOException ex) {

            Logger.getLogger(LeapYrDemo.class.getName()).log
(Level.SEVERE, null, ex);

        }

}



}

Ads









Related Tutorials/Questions & Answers:
leap year
leap year  how to create class for leap year. It is leap year...(); if (year.isLeapYear(y)){ System.out.println("It is a leap year."); } else{ System.out.println("It is not a leap year."); } } } Thanks
leap
leap   Check the given year for leap year (Test Case: 2010, 2012 , 1900
Advertisements
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
ModuleNotFoundError: No module named 'leap'
ModuleNotFoundError: No module named 'leap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'leap' How to remove the ModuleNotFoundError: No module named 'leap' error
ModuleNotFoundError: No module named 'leap'
ModuleNotFoundError: No module named 'leap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'leap' How to remove the ModuleNotFoundError: No module named 'leap' error
ModuleNotFoundError: No module named 'leap'
ModuleNotFoundError: No module named 'leap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'leap' How to remove the ModuleNotFoundError: No module named 'leap' error
ModuleNotFoundError: No module named 'leap-client'
ModuleNotFoundError: No module named 'leap-client'  Hi, My Python... 'leap-client' How to remove the ModuleNotFoundError: No module named 'leap-client' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'leap-client'
ModuleNotFoundError: No module named 'leap-client'  Hi, My Python... 'leap-client' How to remove the ModuleNotFoundError: No module named 'leap-client' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'leap_gwas'
ModuleNotFoundError: No module named 'leap_gwas'  Hi, My Python... 'leap_gwas' How to remove the ModuleNotFoundError: No module named 'leap... have to install padas library. You can install leap_gwas python with following
ModuleNotFoundError: No module named 'leap-protocol'
ModuleNotFoundError: No module named 'leap-protocol'  Hi, My... 'leap-protocol' How to remove the ModuleNotFoundError: No module named 'leap-protocol' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'leap-server'
ModuleNotFoundError: No module named 'leap-server'  Hi, My Python... 'leap-server' How to remove the ModuleNotFoundError: No module named 'leap-server' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'linggle-leap'
ModuleNotFoundError: No module named 'linggle-leap'  Hi, My Python... 'linggle-leap' How to remove the ModuleNotFoundError: No module named 'linggle-leap' error? Thanks   Hi, In your python
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
Logic Building
Logic Building  I wanted to devlop my logic ? How can i do so ? Can i start with java or i need to do c++ before
ModuleNotFoundError: No module named 'leap-second-client'
ModuleNotFoundError: No module named 'leap-second-client'  Hi, My... named 'leap-second-client' How to remove the ModuleNotFoundError: No module named 'leap-second-client' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'mailpile-leap-adapter'
ModuleNotFoundError: No module named 'mailpile-leap-adapter'  Hi...: No module named 'mailpile-leap-adapter' How to remove the ModuleNotFoundError: No module named 'mailpile-leap-adapter' error? Thanks   Hi
Logic Iterate.
Logic Iterate.  I have one doubt about logic:iterate. I use text feild inside of logic:iterate , there is possible will generate N no of rows (text feild) inside of iterate. my doubt is how to get the Paritcular rows text
Logic Iterate.
Logic Iterate.  logic iterate Struts I have one doubt about logic:iterate. I use text field inside of logic:iterate , there is possible... the Particular rows text value. for example: print("<logic:iterate id="xid
Logic and Degin
Logic and Degin  Need help in writing a pseudocode for this can so please help me with this just need to get started. In this lab, you are going to extend the Fireworks Checkout Stand application in Week 6. This week, we
What is programming logic ?
What is programming logic ?  What is programming logic
Logic and Design
Logic and Design  Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January
logic-iterate
logic-iterate  in my code i am using for-each loop for displaying data i want use tag to display data how to use plase help me <%@ page import="java.sql.*" %> <%String[] id = (String[])session.getAttribute("ids
How to calculate days in a year
How to calculate days in a year  Hi, How to calculate no of days in a year? I want a program that calculates no of days in a year by specifying year... of calculating days in a year? Thanks
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year... Year'. To understand and grasp this example, we use the following syntax
Mysql Year of Date
Mysql Year of Date       Mysql Year of Date is used to return the current year of the table in database. Understand with Example The Tutorial illustrate an example from 'Mysql Year
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular... 'Mysql Date Add Year'. To graspe this example, we use Add('2008-12-15',INTERVAL 1
ModuleNotFoundError: No module named 'logic'
ModuleNotFoundError: No module named 'logic'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'logic' How to remove the ModuleNotFoundError: No module named 'logic'
name of year in chinese
name of year in chinese   hello my name kiemtheng i'm come from Cambodia, i would to write java programming to calculate a name of year for each... out put . Enter day of birth: 02 Enter month of birth: 10 Enter year of birth
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
name of year in chinese
name of year in chinese   hello my name kiemtheng i'm come from Cambodia, i would to write java programming to calculate a name of year for each birthday in Chinese but i dont know how to do.   import java.util.

Ads