Comment

Vishal
There is error in your logic....,
August 24, 2009 at 11:39 AM

Hi, My name is Vishal...I think the logic you have given for leap year i.e. (year%4) is not enough to decide whether a year is leap year or not....

Because 1700, 1800, 1900 These are not leap years but still are divisible by 4....

Here is the right logic...

if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
leap;
else
not leap;

View All Comments | View Tutorial
Related Tutorial and Articles
JSP Servlet Questions

Java Beginners

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

Java Beginners

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

Java Beginners

logic - Java Beginners
+"\""); System.out.println(s+"."); } } For more information on Java visit to : http://www.roseindia.net/java/ Thanks

Java Beginners
Java Beginners

Java Error - Java Beginners
Java Error  Hello Sir ,How i Can solve Following Error Can not find Symbol - in.readLine(); Here Error Display at in  Hi Friend, It seems that you haven't defined the object 'in'.Anyways, Send your code so that we

Java Beginners

java code and logic - Java Beginners
java code and logic  Q1: how to write java program for the following: * * * * * * * * * * * * * Q2: S T R I

Java Beginners

java code and logic - Java Beginners
java code and logic  how to write the program in java for 123454321 1234 4321 123 321 12 21 1 1 thanks  Hi Friend, Try the following code: class Program { public static void main(String

Java Beginners

java code and logic - Java Beginners
java code and logic  Q1: PRINT FIRST 100 PRIME NUMBERS? Q2; INPUT A NO. FROM THE USER REVERSE THAT NO. AND INCREMENT IT WITH 1 AND THEN PRINT IT. Q3: HOW TO PRINT THIS STRING s T R

Java Beginners

java error - Java Beginners
been obsoleted. To get the details of your error, compile your class with Xlint...java error  G:\threading>javac threadmethods.java Note: threadmethods.java uses or overrides a deprecated API. Note: Recompile with -Xlint

Java Beginners

java error - Java Beginners
java error  Hello sir, on compiling any program from command prompt.... But if I want to run that program the fetches me the following error. For example for file: Test.java C:\Program Files\Java\jdk1.6.0_17\bin>javac Test.java

Java Beginners

java error - Java Beginners
java error  Thanks for providing me the answer for the question... be dereferenced If Programme saved in SortFileData also shows some error Please rectify the errors and provide the coding that run properly Write a Java program

Java Beginners

JAVA Error - Java Beginners
JAVA Error  i have made my own calculator GUI..and i want the text..."); btnBack.setForeground(red); it send me an error message that goes like this unknown...? your help is very much appreciated!  Hi friend, i am sending

Java Beginners

Error - Java Beginners
to hex. Please have a look on the code. In jsp page I got errors. Error No 1:Incompatible type found,java.lang.objectrequired,java.lang.string. Error No 2:sval already defined in merged scriptlet Error No 3:haval already defined

Java Beginners

what is the error - Java Beginners
what is the error  What is the compile time error that i am getting while compiling the application. Thanks!  SOLUTION :- Your program is creating the compile time error such as : - ? CANNOT FIND SYMBOL ? because you

Java Beginners

deploy jsp using web logic - Java Beginners
deploy jsp using web logic  Hi all, I am new in Web logic server please tell me what is the steps of writing deployee the jsp using web logic. and steps also arrange the folder its urgent

Java Beginners

runtime error - Java Beginners
runtime error  sir run time error is coming again in this code also null pointer Exception at for( File f:contents) import java.io.*; public... Friend, Specify the folder name that is located in your C://RECYCLER. Thanks

Java Beginners

Compiling Error - Java Beginners
Compiling Error  cant able to compile java servlet file in the command prompt? WHY? but i can compile normal java file give me answer to fix my... check it. IF not, then put this jar file in the lib folder of your tomcat

Java Beginners

Error handling - Java Beginners
Error handling  Hello, Help me write code as instructed bellow for a Java program. 1. Create a new Movie class which has two properties, title... arguments. Your Cinema class should also have a setMovie method which takes a Movie

Java Beginners

Servlet error - Java Beginners
..??  Hi Friend, You can simply save your java file in classes...;Cont.. Then your java file and its class file, both get placed in the classes...Servlet error  Can't we place the java files instead of class files

Java Beginners

compilation error - Java Beginners
this program it is giving an error as integer number is too large.why? and what is the reason?  Hi Friend, In Java there are some specific literal... not in the Hexadecimal or Octal. Here is fraction of Java code example which will help you

Java Beginners

to solve the error - Java Beginners
, Your code having error : You not have declare any main method So java.lang.NoSuchMethodError: main error occur and you add this main method...; } } } } } For read more information : http://www.roseindia.net/java/ Thanks

Java Beginners

Error with KeyListeners - Java Beginners
Error with KeyListeners  Here tf1id is Jtextfield,when I implement following code Gives Error Source Code- tf1id.addKeyListener(new KeyAdapter... { //l13.setVisible(false); tf1.setBackground(Color.white); } } }; Error StudRec.java

Java Beginners

compilation error - Java Beginners
; Post your code.  //this is person code!! public class Person... in same package Dog class is being compiled bt. Person is not compiled . error

Java Beginners

compilation error - Java Beginners
compilation error  sir what is the error inthis code after... : C:\>javac -d . Group.java 3)For execute the programm : C:\>java... array for(int i=0;i  Hello your code is correct, i think u r

Java Beginners

Error in a code. - Java Beginners
Error in a code.  This is the question I posted yesterday: "I'm... should give an appropriate error message. The first part works perfectly fine, but the second gives me an error: Exception in thread "main" java.lang.Error

Java Beginners

programming error - Java Beginners

Java Beginners

; Hi Friend, Your code works fine here. Thanks  The error

Java Beginners

compilation error - Java Beginners
the compiler is referring to, then compile your class with the following: javac -Xlint:unchecked Anyways, it will make no harm and your program will get run

Java Beginners

java compilation error - Java Beginners
java compilation error  I need to know how to correct a compiler error for my program to run. The error I keep getting is unclosed string literal... and this is when my compiler error occurs. Let me know if you need any

Java Beginners

db error - Java Beginners
the datatype of the field in which you are inserting your text area content. if you are using mysql then put the datatype as "longtext". repply your

Java Beginners

Java Compilation error - Java Beginners
Java Compilation error  I got this error while convert java to pdf.../size can somebody told me how to handle this error...  Hi Friend, Please send your code. Thanks   Its ok... i already solved

Java Beginners

error - Java Beginners
(String ...s) { new Sum(); } }   Hi Friend, We have modified your

Java Beginners

Programming error - Java Beginners
("Enter Your Name and Email"); out .println(""); out.println

Java Beginners

java compilation error - Java Beginners
the java_home and path in your environmental variables in "My Computer...java compilation error  i have downloaded java software(version 6... command, error message is displayed javac is not recognized as an internal

Java Beginners

java compilation error - Java Beginners
Shireesha.  Hi Friend, As you have mentioned that your java file...java compilation error  Dear Sir ........ I was installed the java soft ware in PC by following your guidelines only, after installing I'm

Java Beginners

java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check

Java Beginners

java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check

Java Beginners

java compilation error - Java Beginners
java compilation error  Hello, I'm having problems with trying.... It's flagging two errors for this one code. The first error says identifier expected and the next error says invalid method declaration; return type required

Java Beginners

Compilation error in java - Java Beginners
Compilation error in java  i have a properties file named... that file in java class,my code is Properties props = new Properties(); File... FileInputStream(f); props.load(in); but i got a error the system could

Java Beginners

Java Compilation error - Java Beginners

Java Beginners

Java compilation error - Java Beginners
Java compilation error  Hello I am having this problem while...\AccountRecord.java I save AccountRecord.java in ch14 However I get an error saying... your code so that we can solve your problem. Thanks

Java Beginners

Error with JCombo Box - Java Beginners
Error with JCombo Box  when i set JComboBox on Tab then Display Error near addItem method,that is Identifer Expected, How I Can remove that Error.  Hi Friend, Please post your code. Thanks

Java Beginners

stateless session bean with methods error - Java Beginners

Java Beginners

compilation error in java - Java Beginners
; Hi Friend, Your are using the char to restoring string values. For removing the error you have to use the String type in place of char & your code...compilation error in java  Here is the pgm usinf if-else statement

Java Beginners

java compilation error - Java Beginners
java compilation error  Hello, I had recently sent an email...); MY ERROR FLAGS HERE public class DisplayImage extends Panel { BufferedImage image; public DisplayImage() { try{ MY SECOND ERROR FLAGS HERE

Java Beginners

Java Compilation Error - Java Beginners
Java Compilation Error   Actually Iam having a packaging. Whatever... imported packages. What ever error iam getting is at the array usage. So, guide me regarding that.  Hi friend, We check your code having some

Java Beginners

java compilation error - Java Beginners
java compilation error  can not find symbol sysbol:method println(int,int,int) location: class java.io.PrintStream) System.out.println(+a,+b,+c);  Hi friend, Please, specify in detail what's your problem

Java Beginners

scanner Class Error - Java Beginners
Class ,there is Error Can not Resolve Symbol-Scanner how i can solve this problem,   Hi Friend, If your Java is not version 1.5 or above, Scanner class is not provided. Check your version.It should work with java 1.5

Java Beginners

java Method Error - Java Beginners
java Method Error  class mathoperation { static int add(int... Errors ,Please Give Me solution of Following Error G:\>javac mathdemo.java... have got those errors. Your code: class mathoperation { static int add

Java Beginners

Java Compilation error - Java Beginners
Java Compilation error  What's wrong with this: public enum...; } } /*error starts here-->*/public static boolean validSelection(char...(response == 'Y' || response = 'y') { System.out.print("Player 1 enter your choice

Java Beginners

java compilation error - Java Beginners
calling other java pgms like k-means and Readfile... when i execute am getting error...java compilation error  package punitha; import java.util.Vector...) { // TODO add your handling

Java Beginners

java compilation error - Java Beginners
java compilation error  here is the rest of my codes. I hope you...) { ProductInventory2.addProduct(temp); repaint(); MY COMPILER ERROR BEGINS BELOW..., cmm0518@yahoo.com  Hi Friend, Your previous errors have been solved but you

Java Beginners

java compilelation Error - Java Beginners
java compilelation Error   import java.lang.*; class prime extends...; Hi Friend, You have used extra braces at the end of the java file, otherwise your code is correct. class prime extends Thread { public void run

Java Beginners

XML DOM error - Java Beginners
) but im getting a error like this... "java.io.IOException: Server returned HTTP... this code works fine.It seems that your code could not find the file that you have... got the error again,then send full error details. Thanks

Java Beginners

readline Error 2 - Java Beginners
readline Error 2  Hi sir, can you look again please. The error is hard to notice, but if you execute the code, 1. enter a string the first input... br.readLine instead of System.in.read, your code will work. Your modified code

Java Beginners

Pleae help me to give logic and code for this program - Java Beginners
://www.roseindia.net/java/beginners/StringReverseUsingStringUtils.shtml...Pleae help me to give logic and code for this program  Write a function that given the string ?original? create a new string ?dramatic? that has two

Java Beginners

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

Java Beginners

explanation to your code - Java Beginners
explanation to your code  sir, I am very happy that you have...)?And i have imported many classes.but in your code you imported a very few classes.sir i need your brief explanation on this code and also your guidance.this

Java Beginners

Java compile time error. - Java Beginners
Java compile time error.  CreateProcess error=2, The system cannot find the file specified  Pleae Describe your query  Hi friend, Please specify in detail and send me code. If you are new java

Java Beginners

With reference to the question " TELL US THE LOGIC OF DICEROLLER"???
With reference to the question " TELL US THE LOGIC OF DICEROLLER"???  Tell us the logic of diceroller 1 Answer(s) 18 minutes and 38 seconds ago Posted in : Java Beginners As told ""The (Math.random()*6)+1 returns the random

Design concepts & design patterns Questions

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... for people living in the zip code". Modularize your code

Java Beginners

programming error - Java Beginners

Java Beginners

syntax error in SQL Insert Statement - Java Beginners
syntax error in SQL Insert Statement  Dear Sir ,I have write following code to save data into access databse, but code gives following error code...)values(?,?)"); Error: java.sql.SQLException: [Microsoft][ODBC Microsoft

Java Beginners

java code compling error - Java Beginners
java code compling error  i have face below problem,when compiling the program? Note: Some input files use unchecked or unsafe operations. Note... this problem?  Hi Friend, Your code downcasts from Object to something

JDBC Questions

Logic - JDBC
the UNION keyword in your sql query. Simply Select statement for first table

Java Beginners

ERROR with my JAVA code - Java Beginners
ERROR with my JAVA code  The error came up in my main method...(null, "The Volume is:"+volume,"for your pool.", JOptionPane.INFORMATION_MESSAGE...); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"" + "for your

Java Beginners

Error with PrintDocument - Java Beginners
Error with PrintDocument  Error: StudRec.java:526: printComponent(java.awt.Component) in PrintableDocument cannot be applied.... Note: Recompile with -Xlint:unchecked for details. 1 error

Java Beginners

Java Error - Java Beginners
Java Error  E:\SUSHANT\Core Java\FileHandling\Error>javac demo1.java demo1.java:15: possible loss of precision found : int required: char ch= reader.read(); ^ 1 error import java.io.

Java Beginners

Java Error - Java Beginners
Java Error  Here Error near Read Method import java.util.*; import java.io.*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println

Java Beginners

Error - Java Beginners

Java Beginners

java compilation error - Java Beginners
java compilation error  Hello madam/sir, i m a beginners in java. My problem is that i want to connect a login form to a frame containing 4 panels. how could i do it?Please help

Java Beginners

Java Program Complication error - Java Beginners
Java Program Complication error  Hi there, I have this program I had to write called ThreeArrayLists.java, but I keep getting this error "use... in quantity are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9 4.8. Your program should pass

Java Beginners

error while running the applet - Java Beginners
error while running the applet  import java.applet.Applet; import...); ++num; } } } } i have problem while running the code , error... classes in the MyFrame class , can you expalin?  Hi Your program

Java Beginners

complier error - Java Beginners
error shows syntax errors like: required : int found : byte Runtime error shows logical errors like: int x=2/0; //this expression causes runtime error Thanks  Hi Friend, Difference: Compile time error shows syntax

Java Beginners

error - Java Beginners
Java error handling  How to write a code to handle the errors in Java?  hi all,visit these site mentioned belowhttp://www.ugrad.cs.ubc.ca/~cs211/tutorials/Eclipse/Eclipse_Java_Windows_XP.htmlit will work

Java Beginners

Java Final Project Error - Java Beginners
Java Final Project Error  It isnt showing the result when I press...); JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"for your pool.", JOptionPane.INFORMATION...,"" + "for your oval hot tube.", JOptionPane.INFORMATION_MESSAGE

Java Beginners

error message - Java Beginners
error message  sir, while i m trying to execute my first program(print my name)I get error message like" javac is not recognized as internal...;Hi friend, To compile and run a java program we need to install java

Java Beginners

Compile time error
; This means java is not configured properly in your system. Please visit... the following link: http://www.roseindia.net/java/beginners/installing_java.shtml... getting a error like "Javac is not a recognized as an internal or external

Java Beginners

java error - Java Beginners
java error  Dear roseindiamembers, I have checked the registration form for new user to login roseindiamembers forum with different data.It's not working properly .when i am registering as new user in http

Java Beginners

Java Error - Java Beginners
Java Error  import java.io.*; import java.lang.*; public class Wrapperdemo { float prin; float rate; int no; float interest; Wrapperdemo() { try{ BufferedReader br = new BufferedReader(new InputStreamReader

Java Beginners

Error - Java Beginners
: Enter the HexaDecimal : I got error in the line String status=session.getAttribute-----> Type of error

Java Beginners

Still getting the http 404 error - Java Beginners
is userid? Anyway, whatever I do, I still receive the http 404 error...saying... in the classes folder of your web application folder and do the servlet

Java Beginners

JBoss - error during deploy - Java Beginners
JBoss - error during deploy  Hello! I've followed your fantastic tutorial about JBoss but I got stucked in exercise 2. I use JBoss AS 5 (don't.... In the latter, the error given is: Failed to create Resource example2.ear - cause

Java Beginners

runtime error - Java Beginners
runtime error  I created a sample java source ,compiled it succesfully using command prompt but when i tried to run i got the folowing error " Exception in thread "main" java.lang.UnsupportedClassVersionError" I have set

Java Beginners

Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error

Java Beginners

syntax error in SQL Insert Statement - Java Beginners
syntax error in SQL Insert Statement   private class ButtonListener... source if }//end action performed }//end listeners  Hi Friend, Your... change your field name 'date' to 'day' and run the following query: int i

Java Beginners

I need your help - Java Beginners
I need your help  What is the purpose of garbage collection in Java, and when is it used?  Hi check out this url : http://www.artima.com/insidejvm/ed2/gc.html http://java.sun.com/javase/technologies/hotspot

Java Beginners

trap error - Java Beginners
trap error  Hello. Am trying to trap this error that appears when i post blank fields to database. "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression". what i want is a message cannot post

Java Beginners

ERROR - Java Beginners
ERROR  Hello Sir i am getting error to this code 1.write a java program to read these strings apple orange banana and display the frist... am getting an error that is StringProgram.java:6: cannot resolve symbol

Java Beginners

Error in POI - Java Beginners
Error in POI  Hi friend, I am working with Excel using POI API.I need to read an excel file and do some modifications and save this file into different location. Along with this I need to remove the extra sheets which

Java Beginners

error detection - Java Beginners
error detection   Hi Amardeep and all friends out... me an error,of "(" or "[" expected. i tried to change everything i can to repair the error but got stuck. please help me to find out what must i do to repair

Java Beginners

Compiling Error - Java Beginners
Compiling Error  cant able to compile java servlet file in the command prompt? WHY? but i can compile normal java file give me answer to fix my problem

Java Beginners

compilation error - Java Beginners
compilation error   import java.awt.*; import java.awt.event.*; import javax.swing.*; class BLayout implements ActionListener { JFrame f ; JPanel jp; JButton b[]; CardLayout cl; BLayout(String s) { jp = new JPanel

Java Beginners

Error - Java Beginners
Error   import java.util.*; import java.io.*; public class inputdemo { public static void main(String[] args) throws IOException { String bookname,author; float price; System.out.println

Java Beginners

Servlet error - Java Beginners
Servlet error  I installed Jdk and tomcat successfully and all the examples provided by the tomcat are running successfully...But i'm unable to run my own servlet program.. The error i'm facing is... exception

Java Beginners

: Java Compilation error. - Java Beginners
: Java Compilation error.  what is the difference between static... on java visit to : http://www.roseindia.net/java/beginners/ http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml Thanks   static

Java Beginners

Compile error - Java Beginners
Compile error  I get this error when compiling my program: java:167... to be thrown tc.countLines(inFile); ^ 1 error... whatever from tc } catch (IOException ioe) { System.out.println("Error

Java Beginners

trap error - Java Beginners
trap error  Hello. Am trying to trap this error that appears when i post blank fields to database. "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression". what i want is a message cannot post blank

Java Beginners

Error - Java Beginners
Error  I compiled 1 java program,it compiled fine,but can't execute... try to solve the error.but i dont know where to correct the error. i am new to java. here following i post the code import java.lang.*; import java.io.