1123123
package com.coe;

public class test {
    public static void main(String[] args){
        System.out.println("练习  4");
        test4();
        System.out.println();
        
        System.out.println("练习  5");
        test5();
        System.out.println();
        
        System.out.println("练习  6");
        test6();
        System.out.println();
        
        System.out.println("练习  7");
        test7();
        System.out.println();
        
        System.out.println("练习  8");
        test8();
        System.out.println();
        
        System.out.println("练习  9");
        test9();
        System.out.println();
        
        System.out.println("练习  10");
        test10();
        System.out.println();
        
    }
    public static void test4(){
        int sum = -1;
        if (sum>0){
            sum =sum+ 100;
        }else{
            sum = sum+500;
        }
        System.out.println(sum);
    }
    public static void test5(){
        int sum = 0;
        if (sum > 0){
            System.out.println("大于0");
        }else if (sum < 0){
            System.out.println("小于0");
        }else{
            System.out.println("等于0");
        }
    }
    public static void test6(){
        double sum = 1.6;
        System.out.println(Math.round(sum));
    }
    public static void test7(){
        int sum = 60;
        if (sum>90){
            System.out.println("优秀");
        }else if(sum > 80){
            System.out.println("良好");
        }else if(sum >70){
            System.out.println("中等");
        }else if(sum >60){
            System.out.println("及格");
        }else{
            System.out.println("不及格");
        }
    }
    public static void test8(){
        int sum = 40;
        int s = 0;
        s = (sum >=90 & sum<=100)?1:(sum >=80 & sum<=89)?2:(sum >=60 & sum<=79)?3:(sum >=0 & sum<=59)?4:0;
        switch(s){
        case 1:
            System.out.println("优秀");
            break;
        case 2:
            System.out.println("中等");
            break;
        case 3:
            System.out.println("及格");
            break;
        case 4:
            System.out.println("不及格");
            break;
        default:
            System.out.println("无效的成绩");
        }
    }
    public static void test9(){
        double sum = 0;
        int i =1;
        while(i<100){
            double temp = i/i+1;
            sum += temp;
            i++;
        }
        System.out.println( sum); 
    }
    public static void test10(){
        int sum = 0;
        int i =0;
        while(i<10){
            int adds = 0;
            for(int j=0; j<(i+1); j++){
                adds += j+1;
            }
            sum += adds;
            i++;
        }
        System.out.println(sum);
    }
}