if-else if问题
import java.util.Scanner;
class test2{
public static void main(String[] args){
System.out.println("请输入您爱宠的年龄:");
Scanner sc1 =new Scanner(System.in);
int dogAge = sc1.nextInt();
if(dogAge > 0 && dogAge <= 2);{
double realAge = 10.5 * dogAge;
System.out.println("狗狗的实际年龄"+realAge);}
else if(dogAge > 2);{
double realAge = 10.5 * 2 + (4 * (dogAge - 2));
System.out.println("狗狗的实际年龄"+realAge);}
else if(dogAge > 30 || dogAge < 0);{
System.out.println("您输入的年龄有误");}
}
}
这里编译不通过,提示说else用法有误.