如何验证布尔值是对还是错

一级

首先,我对我的英语表示歉意。在解释想法,与编程相关的问题时,我仍然很难弄清楚什么是错误的,我想要什么。

编码 :

public static boolean isLeapYearJulian(int year) {
    // Modifier le code ci-dessous
        if (year % 4 == 0) {
            return true;
        } 
        else {
            return false;
        }

    }

    public static boolean isLeapYearGregorian(int year) {
    // Modifier le code ci-dessous
        if ((year % 4 == 0) && (year % 100 != 0) || (year % 4 == 0) && (year % 100 == 0) && (year % 400 == 0)) {
            return true;
        }
        else {
            return false;
        }

    }

    // EXERCICE 2 QUESTION 2
    public static int daysInYearJulian(int year) {
    // Modifier le code ci-dessous
        if (isLeapYearJulian == true) {
            return 366;
        }
        else {
            return 365;
        }
    }

    public static int daysInYearGregorian(int year) {
    // Modifier le code ci-dessous
        if (isLeapYearGregorian == true) {
            return 366;
        }
        else {
            return 365;
        }
    }`

问题是我想看看isLeapYearGregorian和isLearYearJulian是否为真,不知道年份是否为双歧。但是(是的,我是新手,对编程非常陌生),我只是不记得要测试布尔值了。所以很可惜,我要向你们寻求帮助……在此先感谢。

顺便说一句,终端返回此:

Calendar.java:47: error: cannot find symbol
        if (isLeapYearJulian == true) {
            ^
  symbol:   variable isLeapYearJulian
  location: class Calendar
Calendar.java:57: error: cannot find symbol
        if (isLeapYearGregorian == true) {
            ^
  symbol:   variable isLeapYearGregorian
  location: class Calendar
2 errors
用户名

更换

if (isLeapYearJulian == true)

if (isLeapYearJulian(age))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章