我必须编写一个基于英国超速罚款的程序。因此,如果驾驶员在3年内得到12个或更多的罚分,并且如果他/她仍然在2年内通过驾驶考试,他/她将被取消驾驶资格,他/她的驾驶执照将会被撤销(撤回),如果他/她建立6个或更多的惩罚点。Java if语句逻辑&&运算符给出错误
这里是我的程序:
package lesson1;
import java.util.*;
public class MyClass{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
speeding_penalties(13,2);
}
public static void speeding_penalties(int points, int years){
if((points=>12)&& (years<=3)){
System.out.println("disqualified");
}
else if((points=>6)&& (years<=2)){
System.out.println("revoked driving license");
}
}
}
的问题是,我在if
语句得到一个错误,给了我以下错误:
`操作& &是未定义的参数类型(s)int,boolean'
编辑: 谢谢大家的答案!我通过将运算符更改为> =来编辑程序,但仍然在编译程序时,打印语句未出现。
'=>'不是Java中的运算符,而是使用'> ='。 –