Hello guys, I am a beginner in java programming and I am going nuts already :s
Well I am suppose to write an application that will prompt the user 5 times to enter a year and then it will determine whether or not the year is a leap year.
I wrote the application and it determines if the year is leap or not, however it won't prompt the user 5 times to enter a year... There might be very simple way to set it but I am just stuck at this point... My application just asks once...
I'd be so happy if someone can help me with this issue...
Thank you in advance...
\\ here is the code
CODE
import java.util.Scanner;
public class LeapYearApp {
public static void main (String[] args){
Scanner input = new Scanner( System.in );
int year;
{
System.out.print( "Please enter a year. " );
year = input.nextInt();
if ( year % 4 == 0 ) {
if ( year % 100 == 0 ) {
if ( year % 400 == 0) {
System.out.println ( year + " is a leap year." );
}
else {
System.out.println ( year + " is not a leap year." );
}
}
else {
System.out.println ( year + " is a leap year." );
}
}
else {
System.out.println ( year + " is not a leap year." );
}
}
}
}
*edited to add the code tag... much easier to view... much easier to cut & paste
please post your code
This post has been edited by pbl: 13 Oct, 2008 - 08:06 PM