Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:25:51+00:00 2026-05-28T08:25:51+00:00

I have tried a few different methods, like print(boolean isLeapYear) and a few others,

  • 0

I have tried a few different methods, like print(boolean isLeapYear) and a few others, but I can not figure out how to get it to work. It always says that I have a missing class (boolean is primitive, does it need one?) Anyways, If the isLeapYear if-else statements are wrong, I’m not worried about those.. I just need to figure out how to print out the value of the boolean; any help / point in the right direction is greatly appreciated =]

import java.util.Scanner;

public class booleanfun    {
    boolean isLeapYear;

    public static void main(String[] args)
    {
        System.out.println("Enter a year to determine if it is a leap year or not: ");
        Scanner kboard = new Scanner(System.in);
        int year = kboard.nextInt();
    }
public boolean isLeapYear(int year)
  {
    if (year % 4 != 0)
        isLeapYear = false;

    else if ((year % 4 == 0) && (year % 100 == 0))
        isLeapYear = false;

    else if ((year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0))
        isLeapYear = true;

    else
        isLeapYear = false;

System.out.println(isLeapYear);
System.out.println(boolean isLeapYear);

    return isLeapYear;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:25:52+00:00Added an answer on May 28, 2026 at 8:25 am
    System.out.println(isLeapYear);
    

    should work just fine.

    Incidentally, in

    else if ((year % 4 == 0) && (year % 100 == 0))
        isLeapYear = false;
    
    else if ((year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0))
        isLeapYear = true;
    

    the year % 400 part will never be reached because if (year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0) is true, then (year % 4 == 0) && (year % 100 == 0) must have succeeded.

    Maybe swap those two conditions or refactor them:

    else if ((year % 4 == 0) && (year % 100 == 0))
        isLeapYear = (year % 400 == 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to figure this out and googled through a fair few stack
How can I serialize a property with CData? I have tried a few different
I'm not exactly sure how to properly debug this but have tried a few
have tried a few different approaches to this but with no success so far.
I have tried this a few different ways and it always seems to fail.
I have tried quite a few codes but none of them seem to work
i've tried a few different json methods (stringify, toJSON, and probably some totally irrelevant
So I am pretty new to JSP. I have tried this a few ways.
Have tried to find solutions for this and can't really come up with anything.
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.