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...

Live Tiles in Windows 8 do not require an Internet connection

Indicate whether the statement is true or false

Computer Science & Information Technology

What type of information security policy document should define the procedures users should follow if they suspect misuse of corporate computing resources by an employee or other affiliate?

a. Backup policy b. Data retention policy c. Acceptable use policy d. Confidentiality policy

Computer Science & Information Technology