package day02; public class Day04_Multi_IF { public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.println("请输入一个整数"); int x = input.nextInt(); /* (1)x>=3; y=2x+1; (2)-1<=x<3; y=2x; (3)x<-1 ; y=2x-1; */ int y; //多分支语句 if (x>3) { y = 2 * x + 1; }else if (-1<=x&&x<3) { y = 2 * x; }else { y=2*x-1; } System.out.println("y的值是:"+y); } }
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交