Computer Science 252
Problem Solving with Java

Spring 2016, The College of Saint Rose

Lecture 16: Recursion
Date: Thursday, March 24, 2016


Lecture 16 Assignment

Due at the start of class, Tuesday, March 29.

Please submit answers to these questions either as a hard copy (typeset or handwritten are OK) or by email to terescoj AT by the start of class. Please use a clear subject line when submitting by email (e.g., CSC 252 Lecture 16 Assignment, Mary Smith). We will discuss these questions at the start of class, so no late submissions are accepted.

In preparation for the non-graphical recursive methods we'll be working with, let's refresh your memory of how to write methods that compute and return things.

For example, if you were asked to write a method named averageOfThree that takes three double parameters and returns their average, your method might look like this:

    public static double averageOfThree(double a, double b, double c) {

       return (a + b + c)/3;

If asked to write a method named countTheCaps that takes a String as its only parameter, and returns the number of capital letters that occur in the String, your method might look like this:

    public static int countTheCaps(String s) {

        int capCount = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((c >= 'A') && (c <= 'Z')) {
        return capCount;

Now, for your tasks.

Write a program, a Java Application, not a WindowController, with the following functionality:

Please note that all of your methods will need the static qualifier before their return type to be able to be called easily from main (which must always be a static method).