Skip to content

Update LeapYear #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Week 1 Exercise 021 Leap Year/LeapYear
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ public class LeapYear {
System.out.print("Type a year: ");
int thisYear = Integer.parseInt(reader.nextLine());

boolean true4 = (thisYear%4==0);
boolean true400 = (thisYear%400==0);
boolean true100 = (thisYear%100==0);


if ((true400==true)&&(true100==true) && (true4==true)) {
if (thisYear % 400 == 0 && thisYear % 100 == 0) {
System.out.print("The year is a leap year.");
} else if ((true400==false) && (true100==true)) {
System.out.print("This year is not a leap year.");
} else if (true4==true) {
} else if (thisYear % 4 == 0 && thisYear % 100 != 0) {
System.out.print("This year is a leap year.");
} else {
System.out.print("This year is not a leap year.");
Expand Down