java 学习(二)
public class Scoure { public static void main(String args[]) { int score=90; if (score>=85 && score <=100) { System.out.println("优秀"); }else if (score>=65 && score <85) { System.out.println("良"); }else if (score>=60 && score <65) { System.out.println("及格"); }else if (score>=0 && score <60) { System.out.println("不及格"); }else { System.out.println("分数不能大于100 或者小于0"); } } } //if语句的练习
public class lianxi { public static void main(String args[]) { for (int i=100;i<201;i++){ boolean b=false; for (int j=2;j<i-1;j++){ int k =i%j; if (k==0){ b=true; } }if (!b){ System.out.println(i); } } } } //寻找素数100-200
结果:
public class xing { public static void main(String args[]) { for (int i=1;i<5;i++){ for (int j=0;j<4-i;j++){ System.out.print((" ")); } for (int k=0;k<i;k++){ System.out.print("* "); } System.out.println(" "); } } }
运行结果
九九乘法口诀实现
public class suanshu { public static void main(String args[]) { for (int i=0;i<10;i++){ for (int j=1;j<i+1;j++){ System.out.print(String.format("%d*%d=%d",i, j,i*j)); System.out.print(" "); } System.out.println(" "); } } }
结果