Lab 07
Version 1

 

For each of these problems you are asked to write a method. You should, in addition write a simple main method which calls the other method in order to test it.

  1. Write a method which prints the numbers from 1 to 50.

  2. Write a method which takes an int as a parameter and prints the numbers from 1 to that value. Note this method does not get input from the user, it gets its value from the method which calls it.

  3. Write a method which takes an int as a parameter and returns the sum of the numbers from 1 to that value. Note that this method does not get input from the user. It also does not display anything for the user. It simply returns its result to the method which called it.

  4. Write a method which takes two int values as parameters and returns the larger of the two.

  5. Write a method which takes two int values as parameters and uses Euclid's method to compute and return their greatest common divisor.

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Sun, Sep 27, 1998 at 6:08:10 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_07/lab.html