天天看點

Value

1 package JavaMath;
 2 /*
 3     計算在-10.8到5.9之間,絕對值大于6或者小于2.1的整數有多少個
 4  */
 5 public class Work1 {
 6     public static void main(String[] args){
 7         int count = 0;
 8         double min = -10.8;
 9         double max = 5.9;
10         for (int i = (int)min; i <= 5.9; i++){
11             int abs = Math.abs(i);
12             if (abs > 6 || abs < 2.1){
13                 count++;
14                 System.out.println(i);
15             }
16         }
17         System.out.println("一共有"+count);
18     }
19 }