In class practice   Classes and methods

July 09, 2007

Compile and Run following program:

a. Rectangle.java. Please use debug mode to run the code step by step to understand the control-flow of the program.

b. Largest.java. Please use debug mode to run the code step by step to understand the control-flow of the program.

c. printHeading.java. Change the parameters of the method printChars to see what happens.

Programming exercise:

a. Write a method called average that accepts two integer parameters and returns their average as a double. Write code in main function to test the validity the method. 

b. Write a method called sumN that returns the sum of the integers from 1 to N. N is a input parameter. Write code in main function to test the validity the method.

c. In question 2, use one method to print out a desired number of space and asterisk characters.