Asst2.java:27: 错误: 有 ✀if✀, 但是没有 ✀else✀

2024-11-15 07:42:43
推荐回答(1个)
回答1:

错了好几个地方,下面是正确的:

public static void main(String[] args) {

String moun;

Scanner mounth = new Scanner(System.in);

System.out.println("Enter a mounth:");

moun = mounth.nextLine();

String mou = moun.toUpperCase();

mou.substring(0, 3);

int num;

Scanner number = new Scanner(System.in);

System.out.println("Enter a integer:");

num = number.nextInt();

if (20 <= num && num <= 108) {

if (num % 4 == 0) {

System.out.println(mou);

System.out.println("data is :");

System.out.println(num / 4 - 4);

System.out.println(num / 4 - 3);

System.out.println(num / 4 + 3);

System.out.println(num / 4 + 4);

} else

System.out.println("This number is not a multiple of 4");

} else {

if (num < 20)

System.out.println("Number is too small");

else

System.out.println("Number is too large");

}

}