lab7 - 15-121 FALL 2009[CORTINA/REID-MILLER]LAB 7In this...

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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 15-121 FALL 2009 [CORTINA/REID-MILLER]LAB 7In 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 factorialthat has one parameter, a positive integer n, and returns n-factorial. n! = 1*2*3*...*n In a comment write what is the largest value of n, for which factorialgives correct values? (HINT: the smallest n that it incorrect is not when it returns a negative number.) How do you know it is incorrect? Can you write a tester to find this n? Change your method to use longinstead of int. Now what is the largest value of n for which factorialgives correct values? 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....
View Full Document

This note was uploaded on 12/19/2009 for the course CS 121 taught by Professor Reid-miller during the Spring '09 term at Carnegie Mellon.

Page1 / 2

lab7 - 15-121 FALL 2009[CORTINA/REID-MILLER]LAB 7In this...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online