我当前带有逻辑 II OR 的 if 语句有编译错误
My current if statement with the logical II OR is having compile error
我正在学习 Java,但以下代码无法正常工作,您能检查一下我做错了什么吗?谢谢
public class HelloWorld{
public static void main(String []args){
/*
Ticket price: 10 normally
Discounted price , 5 for:
- Age 15 and under
- Over the age 60
- Students
*/
int ticketPrice = 10;
int age = 16;
boolean isStudent = false;
if( (age =< 15) || (age>60) ){
ticketPrice = 5;
}else if (isStudent){
ticketPrice = 5;
}
System.out.println("The price is: "+ ticketPrice);
}
}
是<=(小于或等于),不是=<
。
public class HelloWorld
{
public static void main(String []args)
{
/*
Ticket price: 10 normally
Discounted price , 5 for:
- Age 15 and under
- Over the age 60
- Students */
int ticketPrice = 10;
int age = 16;
boolean isStudent = false;
if ( (age <= 15) || (age>60) || (isStudent) )
ticketPrice = 5;
System.out.println("The price is: "+ ticketPrice);
}
}
我正在学习 Java,但以下代码无法正常工作,您能检查一下我做错了什么吗?谢谢
public class HelloWorld{
public static void main(String []args){
/*
Ticket price: 10 normally
Discounted price , 5 for:
- Age 15 and under
- Over the age 60
- Students
*/
int ticketPrice = 10;
int age = 16;
boolean isStudent = false;
if( (age =< 15) || (age>60) ){
ticketPrice = 5;
}else if (isStudent){
ticketPrice = 5;
}
System.out.println("The price is: "+ ticketPrice);
}
}
是<=(小于或等于),不是=<
。
public class HelloWorld
{
public static void main(String []args)
{
/*
Ticket price: 10 normally
Discounted price , 5 for:
- Age 15 and under
- Over the age 60
- Students */
int ticketPrice = 10;
int age = 16;
boolean isStudent = false;
if ( (age <= 15) || (age>60) || (isStudent) )
ticketPrice = 5;
System.out.println("The price is: "+ ticketPrice);
}
}