标签:ext new ann def == else port ati can
1.
package xx;
import java.util.Scanner;
public class pika {
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int a = in.nextInt();
if(a==1 || a==5 || a==10) {
System.out.println("x="+a);
}else {
System.out.println("x=none");
}
}
}
2.
package xx; import java.util.Scanner; public class pika { public static void main(String[] args) { Scanner in =new Scanner(System.in); int a = in.nextInt(); switch(a) { case 1: case 5: case 10: System.out.println("x="+a); break; default:System.out.println("x=none"); } } }
3.
package xx; import java.util.Scanner; public class pika { public static void main(String[] args) { Scanner s = new Scanner (System.in); System.out.print ("请输入一个数: "); int i = s.nextInt(); if (i%5==0 && i%6==0) { System. out.println (i+"能同时被5和6整除"); } else if(i%5==0) { System. out.println(i+"能只被5整除"); } else if (i%6==0) { System. out.println(i+"能只被6整除"); } else { System. out.println(i+"不能被5和6整除"); } } }
4.
package xx; import java.util.Scanner; public class pika { public static void main(String[] args) { Scanner sc= new Scanner(System.in); System.out.println("请输入分数的值"); int x=sc.nextInt(); if(x<0 || x>100) { System.out.println("打印分数无效"); }else if(x/10>=9 && x/10<=10) { System.out.println("A"); }else if(x/10>=8 & x/10<9) { System.out.println("B"); }else if(x/10>=7 & x/10<8) { System.out.println("C"); }else if(x/10>=6 & x/10<7) { System.out.println("D"); }else if(x/10<6) { System.out.println("E"); } } }
标签:ext new ann def == else port ati can
原文地址:https://www.cnblogs.com/wishings/p/12573211.html