![]() |
School of Engineering and
Applied
Science Department of Computer Science CSci 53 -- Introduction to Software Development http://www.seas.gwu.edu/~csci53/fall05 Prof. Michael B. Feldman mfeldman@gwu.edu |
while(value < 25)
{
value += 5;
System.out.println ("The value is 11 + value);
}
if (x == 1)
y = 5;
else
z = 10;
but we require
if (x == 1)
{
y = 5;
}
else
{
z = 10;
}
and will grade accordingly. This might seem like a lot of extra work, but it pays off later. To see this, consider adding the statement p = 4; to the block containing y = 5; In the first case, you'd have to remember to add braces; in the second case, the braces are already there, so just add the statement!
while (value < 25)
{
value += 5;
System.out.println ("The value is 11 + value);
}
|
|
|
|
if
(x <
5)
{ y = 9; } else { if (x > 25) { y = 100; } else { y = 0; } } |
if
(x <
5)
{ y = 9; } else if (x > 25) { y = 100; } else { y = 0; }
|
//---------------------------------------------------
// Header block
//---------------------------------------------------//***************************************************
// Header block
//***************************************************