day08-static应用-Math类-操作练习
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user