I want to print numbers in the range of 0 to 3 like this:
0, 0.1, 0.2, 0.3, …, 3
but when I'm using this code:
double i = 0;
while (i <= 3) {
System.out.printf("%.1f, ", i);
i+= 0.1;
}
or this:
double j = 0;
do {
System.out.printf("%.1f, ", j);
j+= 0.1;
} while (j <= 3);
i get
0, 0.1, 0.2, 0.3, …, 2.9
What I'm doing wrong?