1. Engineering
  2. Computer Science
  3. write a java class that computes and prints all the...

Question: write a java class that computes and prints all the...

Question details

Write a Java Class that computes and prints all the leap years between a starting and ending year. A year is a leap year if it meets one of the two conditions below:

1. A year is a leap year if it is divisible by 4 and not divisible by 100 (For example, 1980).

2.A year is a leap year if it is divisible by 400 (for example, 2000)

Write a program that does the following:

1. Prompts the user for the starting year

2. Prompts the user for the ending year

3. Prints all the leap years between the start year and the ending year separated by a space

4. Ten years or less will be printed on each separate line of output

5. At the end, the program will print the total number of leap years between the start and end years entered by the user

Ask the user for the starting year and ending year on separate lines

Use a loop to generate the years between the start year and the end year

Include the leap years in the output in the following format:

1. Years separated by a space

2. No more than 10 years printed on any one line

At the end, the program will print the correct total number of leap years between the start and end years entered by the user

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution