day08-static应用-Math类-操作练习

This commit is contained in:
2026-01-22 11:28:38 +08:00
parent b8aff9d0c6
commit e7d434aabf

View File

@@ -7,4 +7,19 @@ package com.inmind.math04;
定义一个变量来计数
*/
public class Test16 {
public static void main(String[] args) {
double start = -10.8;
double end = 5.9;
int count = 0;
for (double i = Math.ceil(start); i < end ; i++) {
System.out.print(i+" ");
//条件>6||<2.1
if (Math.abs(i) > 6 || Math.abs(i) < 2.1) {
count++;
}
}
System.out.println();
System.out.println(count);
}
}