What is wrong with the following code fragment? Rewrite it so that it produces correct output.

```
if (total == MAX)
if (total < sum)
System.out.println("total == MAX and < sum.");
else
System.out.println("total is not equal to MAX");
```


Despite the indentation, the else clause is associated with the immediately preceding if rather than the first if. The program will produce the correct output if it is rewritten as:
```
if (total == MAX)
{
if (total < sum)
System.out.println("total == MAX and < sum.");
}
else
System.out.println("total is not equal to MAX");
```

Computer Science & Information Technology

You might also like to view...

Given the function prototype, what is wrong with the following function call?

void test (int, int&); // function prototype test (a, &b); // function call

Computer Science & Information Technology

A ________ is an image displaying only the outline of a three-dimensional object.

(a) wireframe. (b) symbol. (c) frame. (d) 3-D map.

Computer Science & Information Technology

The New Slide option appears on both the ________ and Insert tabs

Fill in the blank(s) with correct word

Computer Science & Information Technology

The ________ provides a description of these suggestion consequences when you select a specific suggestion

A) Performance Analyzer B) Performance Manager C) Linked Table Manager D) Linked Table Analyzer

Computer Science & Information Technology