Programming and Problem Solving with Java

(やまだぃちぅ) #1

696


while(count <= 10 )
{
num = Integer.parseInt(in.readLine());
if(num == 0 )
{
count++;
num = 1 ;
}
out.println(num);
out.println(count);
}

As a basic rule in this text, each nested or lower level item is indented by two spaces.
Exceptions to this rule are parameter declarations and statements that are split across two
or more lines. Indenting by two spaces is a matter of personal preference. Some people pre-
fer to indent by more spaces.
In this text, we prefer to place the braces on separate lines so that it is easy to scan down
the left edge of a block of code and find them. Placing them on separate lines also reminds
us to consider whether the beginning or the end of a block would benefit from an in-line com-
ment and automatically gives us a place to write one. This is just one style of placement, and
you will encounter other styles as you examine code written by other programmers.
Free download pdf