| |
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.
- Write a method which prints the numbers from 1 to 50.
- 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.
- 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.
- Write a method which takes two
int values as parameters
and returns the larger of the two.
- Write a method which takes two
int values as parameters
and uses Euclid's method
to compute and return their greatest common divisor.
|