samedi 31 mars 2018

I can't get my program to print out a Leap year

The last method I was trying to get it to print out my program can't seem to get it to do it. I don't know what to do. And I'm in an online class so there is no one I could really ask. My teacher takes three days to reply.

import java.util.Scanner;

public class LeapYear {

public static void main(String[] args) {
displayInstructions();
int year = getYear();
isLeap(year);
}

public static void displayInstructions() {
    System.out.println("This program asks you to enter a year as a 4 digit number. The output will indicate whether the year you entered is a leap year.");
}

public static int getYear() {
Scanner reader = new Scanner(System.in);
System.out.println("Enter a year: ");
int year = reader.nextInt();
return year;
}

public static boolean isLeap(boolean year) {
    boolean isLeapYear = false;
    if (year % 4 == 0 && year != 100) {
        isLeap = true;

    }
    else {
        isLeap false;
    }



}
public static void displayResuls( boolean isLeap, boolean year) {
  if (isLeap)
  {
    System.out.println("Year" +year+" is a Leap Year.");
  }

  else {
  System.out.println("Year" +year+" is not a Leap Year");

  }

    }
}

Aucun commentaire:

Enregistrer un commentaire