Find the error in the code segments, and explain how to correct it:

```
for (k = 0.1; k != 1.0; k += 0.1) {
2 System.out.println(k);
3 }
```


Error: Using a floating-point number to control a for statement may not work, be- cause floating-point numbers are represented only approximately by most comput- ers.
Correction: Use an integer, and perform the proper calculation to get the values you desire, as in:

Computer Science & Information Technology

You might also like to view...

Program code that can be evaluated to a value is called a(n)

A) operation. B) line. C) evaluator. D) result. E) expression.

Computer Science & Information Technology

What statements are in the body of the following loop?

``` Set Number = 12 For (I = 1; I <= 15; I++) Write “Enter a number: “ Input Number Write “That’s a good number.”. End For Write “Bye bye.”.``` a. ```Set Number = 12 Write “Bye bye.”.``` b. ```Write “Enter a number: “ Write “That’s a good number.”.``` c. ```Write “Enter a number: “ Write “That’s a good number.”. Write “Bye bye.”.``` d. Input Number

Computer Science & Information Technology

What issues will affect your choice of color management option?

What will be an ideal response?

Computer Science & Information Technology

The motherboard is the main circuit board that houses much of a computer's electronics.?

Answer the following statement true (T) or false (F)

Computer Science & Information Technology