Home Answers Viewqa Java-Beginners leap year logic

 
 


sreekanth
leap year logic
3 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

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);

        }

}



}









Related Pages:
leap year logic - Java Beginners
leap year logic  hi frds.. can u give me logic for leap year..  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/Leapyear.shtml Thanks
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
java leap year
whether itis a leap year. Aleap year is an integer greater than 1584...(); if (year.isLeapYear(y)){ System.out.println("It is a leap year."); } else{ System.out.println("It is not a leap year
Java Leap Year Problem
Java Leap Year Problem  I need help with a writing a program in Java that creates a class Year that contains a data field that holds the number of months in a year and the number of days in a year. It should include a get method
Leap Year Program
the user if it's a leap year or not. It uses boolean operators instead... whether a give year is leap year or not. // Michael Maus, 22 Sept 2004 import... String leapResult; // Tell's whether it's a leap year
Checking whether a year is leap or not
Checking whether a year is leap or not   ... for checking whether a year is a leap year or not. Here, we have taken the year 2000. So...;if else" condition. As we know leap year is divided by the integer 4 and so
Determining If a Year is a Leap Year in Java
Determining If a Year is a Leap Year in Java       Leap Year: Leap Year is the year contains an extra day. In the leap year, February month contains 29 days since normally
Listing out leap years between certain period
.  As we know a leap year is divisible by 4, define an integer l=n%4. So if 'n' is divisible by 4 or l=0, then the particular year can be a leap year... will be a leap year. For listing out each year write "+n"
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
Logic error? HELP PLEASE! :(
Logic error? HELP PLEASE! :(  Hello Guys! i have a huge problem. What..."); String MakeYear = rs.getString("car_year_of_make..._model(carmodel); retrievebean.setCar_year_of_make(MakeYear
Calendar
of the Gregoriancalendar class and also checking whether the year is leap or not and printing... format of the days for this month. We are also checking whether the year is leap or not. Description of program:  In the given example first we
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
wrong year
wrong year..   I think u are using other calendar Check Settings
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
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
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year. Understand with Example The Tutorial illustrate an example from 'Mysql Date Get Year
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
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 programming logic ?
What is programming logic ?  What is programming logic
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular date... Year'. To graspe this example, we use Add('2008-12-15',INTERVAL 1 YEAR) query
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.
WEB LOGIC - JSP-Servlet
WEB LOGIC project  I want the procedure to run a project in we logic server
the business logic is executed.
the business logic is executed.  In which method of Action class the business logic is executed
JSP Financial Year Table
JSP Financial Year Table  Im trying to design a financial year table...wherein the user enters the data in the table and the same is updated in backend.i have successfully desinged the page but i have certain doubts in jsp
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
struts logic tags
struts logic tags  what is the use of struts logic tag   The purpose of Struts logic tags is to alter output depending on the given...://www.roseindia.net/struts/struts-logictags/logic-tags-introduction.shtml http
About Web-Logic
the Web-Logic with Tomcat 5.0 version in Console. Somebody has suggested to see the webpage (they had given the link).But when i installed the Web-Logic i... folder in the Web-Logic
Struts logic iterate
Struts logic iterate  This is my jsp page in which i used 3 logic...; <%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>...; <body> <h1> Search </h1> <logic:iterate name
logic for pattern program
logic for pattern program  what's the logic for create pattern program how can i create any pattern program with in minute. like this 123454321... create this program in java without help whats the logic how can i understand
logic iterate tag - Struts
logic iterate tag  Hey I am displaying the values in a jsp called categoryView.jsp using logic iterate tag as Now properties bname and quant belongs to another formbean named as ViewCategoryForm.java.When I
How to Addding 1 Year with PHP
How to Addding 1 Year with PHP  Hi, I am very fresh in PHP language. I trying to create a small application about how to adding 1 year in specific date. Please suggest me. Thanks
logic for c language
logic for c language  01 02 03 04 05 06 20 21 22 23 24 07 19 32 33 34 25 08 18 31 36 35 26 09 17 30 29 28 27 10 16 15 14 13 12 11
Tell us the logic of diceroller
Tell us the logic of diceroller  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class DiceRollerServlet extends... is " +dice2); } } dice1 =3 dice2 =2 How is the logic executed????   
Please explain the logic....
Please explain the logic....  class A1 { } class B extends A1 { } public class ComingThru { static String s = "-"; public static void main(String[] args) { A1[] aa = new A1[2]; B[] ba = new B[2
Business Logic in mvc2 - JSP-Servlet
Business Logic in mvc2  What is business logic and where it is written using servlet and jsp
ATM Logic - Java Beginners
ATM Logic   Q-In an ATM program i want to print the receipt in which there is information of rupees note that come out from an ATM machine when user enters the particular amount. For e.g. if user enters 2250 then he should get
<logic:iterate> - Struts
is the jsp my PROBLEM IS IAM NOT GETTING THE LIST FROM THE LOGIC ITERATE ?? DID I DID
struts logic:iterate tag
struts logic:iterate tag  Hi All, I am writing a look up jsp which is using logc:iterate every thing is fine except this the problem here is unable to go inside the tag. Here is the stack trace I am getting. [#|2010-10-27T00
Java converts any given year to Roman Numeral
Java converts any given year to Roman Numeral  Write a program that converts any given year to Roman Numeral