运行结果:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/a50f4bfbfbedab64481fe5c8fb36afc379311e4c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/42a98226cffc1e17d2e124394690f603738de958?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/faedab64034f78f0ba6632fb75310a55b3191c4c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
代码如下:
import java.util.Scanner;
public class App65 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入x值:");
int x = scanner.nextInt();
int y = 0;
if (x < 0) {
y = x * x;
} else if (x >= 0 && x < 10) {
y = 2 * x - 1;
} else if (x >= 10) {
y = 3 * x - 11;
}
System.out.println("y=" + y);
}
}