Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION A year with 366 days is called a leap year. Leap years are necessary to keep the calendar synchronised with the sun because

JAVA QUESTION

A year with 366 days is called a leap year. Leap years are necessary to keep the calendar synchronised with the sun because the earth revolves around the sun once every 365.25 days. Actually, that figure is not entirely precise, and for all dates after 1582 the Gregorian correction applies. 1. Usually years that are divisible by 4 are leap years: for example, 2020. 2. However, years that are divisible by 100 (for example, 1900) are not leap years, but years that are divisible by 400 are leap years (for example, 2000). Write a program that asks the user for a year and computes whether that year is a leap year.

import java.util.Scanner;

public class LeapYear

{

public static boolean isLeapYear(int year)

{

// INSERT YOUR CODE HERE

}

public static void printLeapYear(int year)

{ System.out.println("Year " + year + " is" + (isLeapYear(year) ? "" : " not") + " a leap year");

}

public static void main(String[] args)

{ printLeapYear(2020);

printLeapYear(2000);

printLeapYear(1900);

System.out.println("Enter a year: ");

Scanner scanner = new Scanner(System.in);

int year = scanner.nextInt();

printLeapYear(year);

// end of method main

} // end of method main

} // end of class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago