0% found this document useful (0 votes)
3 views2 pages

Leap Year Calculation in Java

This Java program prompts the user to enter their name and age. It then calculates the user's date of birth by subtracting their age from the current year. The program determines if the user's date of birth year is a leap year. It also checks if the user's age corresponds to a World Cup year and prints a relevant message.

Uploaded by

shemar mills
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Leap Year Calculation in Java

This Java program prompts the user to enter their name and age. It then calculates the user's date of birth by subtracting their age from the current year. The program determines if the user's date of birth year is a leap year. It also checks if the user's age corresponds to a World Cup year and prints a relevant message.

Uploaded by

shemar mills
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

[Link].

println("Year " + year + " is a leap year");


else
[Link]("Year " + year + " is not a leap year");

import [Link];

public class Main {

public static void main(String[] args) {


[Link]("Enter your name and age respectively: ");

Scanner scan =new Scanner([Link]);


String Name = [Link]();

Scanner get_info = new Scanner([Link]);


int Age = [Link]();

int DOB= 2017- Age;


[Link]("Your Date of Birth is: "); // Prompt the user
for D.O.B
[Link](DOB); // Print Date of Birth

if ((DOB % 4 == 0 || DOB % 100 != 0)) { //If Condition


//[Link]("This was a World Cup year: ");
int Worldcup=1998; //initializing world cup

//if ( DOB>1998) {//Start if method


//int WC = DOB-1998;
int WorldC=1998 + Age;

if ((WorldC % 400 == 0|| (WorldC % 100 == 0))


){//Begin if Condition

[Link]("This yearr was a World


Cup year: ");
//[Link](DOB);

}//End if condition
else {

[Link]("Not a good year for


you");
}
}//End if

}
}

You might also like