The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Testing assistance, please by radiowave9112006-11-19 12:55:59
  How to tell if it's leap year: by austinkp 2006-04-02 22:48:20
I did this in a beginning java class a couple years ago. Leap year started in 1582. Glad I still have the file:

//**************************************************************
// LeapYear.java Author:Austin Petersen 28 Jan 2003
//
// Determines if a year is a leap year
//**************************************************************

import java.io.*;

public class LeapYear
{
public static void main (String[] args) throws IOException
{

BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

int year;
final int MINYEAR = 1582;
boolean leapYear;

do
{
System.out.print ("Enter a year (at least 1582): ");
year = Integer.parseInt (stdin.readLine());
}
while (year < MINYEAR);


//System.out.println ("You entered: " + year);

if (year%4 == 0)
if ((year%100 == 0) && (year%400 != 0))
leapYear = false;
else
leapYear = true;
else
leapYear = false;


if (leapYear == true)
System.out.println ("Yes, that is a leap year.");
if (leapYear == false)
System.out.println ("No, that is not a leap year");

}
}
[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)