CS 305j - Discussion Assignment



Before you go to discussion this Tuesday, you should work the exam 1 review sheet as well as the following:

1.  Complete the following program by adding the getStairs method.
public class Stairs{

public static void main(String args[])
{
// fill in the function below such that the following statement:
System.out.println(getStairs(2,4,10));

//prints out output that looks like the following:

/*
====
====
========
========
============
============
================
================
====================
====================
========================
========================
============================
============================
================================
================================
====================================
====================================
========================================
========================================
*/
}

2. Programming exercise #3, Chapter 3G, p. 218, of Reges and Stepp.

3. Write a method called printLetters that takes a String as its argument and prints the letters in the String, separated by commas. If the argument is "happy", then the method prints:
h, a, p, p, y
Note that this is a fencepost problem, so you will need to handle printing one of the letters either before or after the loop.

4. Write a method CountA that takes a String and returns the number of times the character 'a' or 'A' appears in the String.