Exercise
4 ?Layout
Here is a section of a Java program
where no layout convention has been enforced. It is a complete mess. Use
indentation, spaces and blank lines as appropriate to tidy up the program
and make it easier to follow. Compare your solution with the suggestions
given in the answer, and see which you prefer.
class
Untidy { int result; public static void main (String
args) {
int
x = calculate(); show(x); }
void
show(int x) { System.out.println(x);
}
int
calculate() { result = 0;
for (int i = 0; i < 100; i++)
result
= result + i; return result; } }
Answer
Back
to content
Back
to top
RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex
University. All rights reserved.
webmaster@globalcampus.com.eg
|