Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误:二进制运算符'&&';第一种类型int和第二种类型boolean_Java - Fatal编程技术网

Java 错误:二进制运算符'&&';第一种类型int和第二种类型boolean

Java 错误:二进制运算符'&&';第一种类型int和第二种类型boolean,java,Java,我是java新手,我非常喜欢这种新的学习体验。 我被分配了一项任务,我们必须创建一个简单的日历,用户需要在其中输入一个日期,程序需要告诉您这是一个正确的日期 但是,我收到一个错误代码,它使用了错误的操作数类型。我不能将int与布尔类型一起使用。然而,我似乎无法找到问题所在 欢迎提供所有帮助和见解 public static void main(String[] args) { Scanner userInput = new Scanner(System.in); // Creatin

我是java新手,我非常喜欢这种新的学习体验。 我被分配了一项任务,我们必须创建一个简单的日历,用户需要在其中输入一个日期,程序需要告诉您这是一个正确的日期

但是,我收到一个错误代码,它使用了错误的操作数类型。我不能将int与布尔类型一起使用。然而,我似乎无法找到问题所在

欢迎提供所有帮助和见解

public static void main(String[] args) {

    Scanner userInput = new Scanner(System.in);  // Creating the new Scanner

    System.out.print("Choose a day: ");            //Asking for user to introduce a day
    int day = userInput.nextInt();

    System.out.print("Choose a month: ");           // Asking user to introduce a month
    int month  = userInput.nextInt(); 

    System.out.print("Choose a year: ");            //Asking user to introduce a year
    int year  = userInput.nextInt(); 


    if ( (1<= day <= 31) && (1 <= month <= 12) && (year >= 0)){     //marking the limits of day, month and year
        System.out.println(" Congratulations, the date you introduced : " + day + month + year +"exists!!");
    } else if ( (day > 30) && (month = 2 || 4 || 6 || 9 || 10) && (year >= 0)){             //marking the months wich have 30 days
        System.out.println(" Oh no, the date you introduced : " + day + month + year +" does Not exists!! You can always try again");
    }else if ( (day > 28) && (month = 2) && (year >=0)){                //marking month February
       System.out.println(" Oh no, the date you introduced : " + day + month + year +" does Not exists!! You can always try again");
    } else {
        System.out.println(" Oh no, the date you introduced : " + day + month + year +" does Not exists!! You can always try again");
    }

}
publicstaticvoidmain(字符串[]args){
Scanner userInput=new Scanner(System.in);//创建新的扫描仪
System.out.print(“选择一天:”;//要求用户介绍一天
int day=userInput.nextInt();
System.out.print(“选择月份:”;//要求用户介绍月份
int month=userInput.nextInt();
System.out.print(“选择年份:”;//要求用户介绍年份
int year=userInput.nextInt();
如果((1 28)和&(月=2)和&(年>=0)){//2月份
System.out.println(“哦,不,您介绍的日期:“+day+month+year+”不存在!!您可以随时重试”);
}否则{
System.out.println(“哦,不,您介绍的日期:“+day+month+year+”不存在!!您可以随时重试”);
}
}
如果((天>=1&&day=1&&month=0)),则必须使用


另外,对于每个月,您需要将
month==2 | | month==4…
1
month=2
看起来是错误的。