Java Learning (2), java Learning
Public class Scoure {public static void main (String args []) {int score = 90; if (score> = 85 & score <= 100) {System. out. println ("excellent");} else if (score> = 65 & score <85) {System. out. println ("good");} else if (score >=60 & score <65) {System. out. println ("pass");} else if (score> = 0 & score <60) {System. out. println ("fail");} else {System. out. println ("score cannot be greater than 100 or less than 0") ;}}// if statement exercise
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) ;}}// find the prime number 100-200.
Result:
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(" "); } }}
Running result