public class FloatRangeProgram {
public static void main(String[] args) {
// Define the range parameters.
final double start = 0.0;
final double step = 0.1;
final int count = 11; // Generates 0.0 through 1.0 inclusive
/*
* Use an integer loop variable.
* Each floating-point value is computed independently.
*/
for (int i = 0; i < count; i++) {
double value = start + (i * step);
System.out.printf("%.1f%n", value);
}
}
}
/*
run:
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
*/