This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 15121 FALL 2009 [CORTINA]LAB 7  due Friday, Oct 30 by 9PMIn this lab, you will implement several recursive methods. EXERCISESDownload the project Lab7.zip. This project has three classes, one for each exercise below. Complete the required methods below. 1. Write a recursive method sumthat has one parameter, a positive integer n, and returns the sum of the positive integers from 1 to n. 2. Write a recursive method countthat has two parameters, a string and a character, and it returns the number of times the character appears in the string. You may only use the following String methods as necessary: charAt, substring, equals, length. HINT: The number of times a character appears in a string is 1 (if the character matches the string's first character) + the number of times the character appears in the rest of the string. 3.[HARDER]Write a recursive method makePermutationsthat has a string as its parameter and returns an array list containing all strings that are permutations of this string. A permutation is a string returns an array list containing all strings that are permutations of this string....
View
Full
Document
 Spring '09
 ReidMiller

Click to edit the document details