Class RecursionLab

java.lang.Object
  extended by RecursionLab

public class RecursionLab
extends java.lang.Object

CPE 103 Lab. Simple recursion programs.

Author:
(your names)

Constructor Summary
RecursionLab()
           
 
Method Summary
static int arrayPosTotal(int[] items, int index)
          Find the sum of the positive integers in an array (or part thereof) of ints.
static int arrayTotal(int[] items, int index)
          Find the sum of the integers in an array (or part thereof) of ints.
static int countSpaces(java.lang.String sentence)
          Count the number of blank spaces in a string.
static int findMax(int[] items, int index)
          Find the largest integer in an array (or part thereof) of ints.
static boolean isPalindrome(java.lang.String sentence)
          Determine if a string is a palindrome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecursionLab

public RecursionLab()
Method Detail

arrayPosTotal

public static int arrayPosTotal(int[] items,
                                int index)
Find the sum of the positive integers in an array (or part thereof) of ints.

Parameters:
items - the array of numbers to be totalled.
index - the starting index of the portion of the array to be totalled (assuming the first position is index zero).
Returns:
the sum of the positive integers from position "index" to the end of the array, or zero if the list has no items.

arrayTotal

public static int arrayTotal(int[] items,
                             int index)
Find the sum of the integers in an array (or part thereof) of ints.

Parameters:
items - the array of numbers to be totalled.
index - the starting index of the portion of the array to be totalled (assuming the first position is index zero).
Returns:
the sum of the items from position "index" to the end of the array, or zero if the list has no items.

countSpaces

public static int countSpaces(java.lang.String sentence)
Count the number of blank spaces in a string.

Parameters:
sentence - string to evaluate.
Returns:
the number of blank spaces in the sentence.

findMax

public static int findMax(int[] items,
                          int index)
Find the largest integer in an array (or part thereof) of ints.

Parameters:
items - the array of numbers to be searched.
index - the starting index of the portion of the array to be searched (assuming the first position is index zero).
Returns:
the largest integer found from position "index" to the end of the array, or zero if the list has no items.

isPalindrome

public static boolean isPalindrome(java.lang.String sentence)
Determine if a string is a palindrome.

Parameters:
sentence - string to evaluate.
Returns:
true if the sentence reads the same forwards and backwards.