Fall 2012, The College of Saint Rose

Lecture 23: Methods with Return Values
Date: Thursday, November 29, 2012

Agenda

• Announcements
• Lecture assignment 22 recap
• In-class exercise

Modify the MonteCarloPi program you worked with last class so it computes the approximation not only for the specified number of points, but all numbers of points which are multiples of 100 from 100 up to 10000. In each case, use your new method estimatePi to perform and report the result. Also modify the printout at the end of estimatePi to include the number of points used to make the approximation.

Submit just the updated MonteCarloPi.java file in Blackboard under the "Lecture Assignment Submissions" category to the "Lecture 23 In-Class Exercise" item. This will earn you 5 lecture assignment points.

• Returning information from methods
• Lab 10: Methods

Due at the start of class, Tuesday, December 4.

Please submit answers to these questions in Blackboard by the start of class. We will discuss these questions at the start of class, so no late submissions are accepted.

• Draw or describe the memory diagram (all variables in existence, and in which method each is visible, plus their current values) for the Distance example, at the point in its execution where the distance method is about to return its result for the call that computes the distance between (3,4) and (-2.9,7). (5 points)
• Gaddis Algorithm Workbench exercise 5, p. 289 (2 points)

Examples