Homework 5
CS201, Spring 2004


Due: 10AM, Friday, May 21

Please email your solutions to csun@calstatela.edu, and make sure to use CS201 Spring 04 HW5 as the subject of the email. The email should include your name, the .java files for all the exercises as attachments. I will check email timestamps, and late homework will not be accepted.


1. (15pt) Write a method squareOfAsterisks that displays a solid square (the same number of rows and columns) of asterisks whose side is specified in integer parameter side. For example, if side is 4, the method displays the following pattern:
****
****
****
****
Write a Java program to test your method. [This problem is adopted from D&D Ex 6.18]

2. (15pt) [D&D] Ex 6.29. Write a Java application instead of an applet, and use either System.out.println or JOptionPane.showMessageDialog for outoput.

3. (20pt) Write a recursive method numOfZeroes() to count the number of 0 digits in an interger. For example, numOfZeroes(100) should return 2, while numOfZeroes(1234) should return 0. Write a Java program to test your method.

4. (30pt) [D&D] 6.14 and 6.36. Ignore the requirements about applets or JTextfield. Just include both methods in a Java application and test them properly.