Lab 3 - Loops
Due: Wednesday, September 28 at 11:59pm
Note: Changes have been made 9/26/05 (written in bold)

Introduction

This lab is designed to build experience using loops. In it, you'll make use of each of the "for" and "while" loops.

The Assignment

Please write a method that computes the nth number in the Fibinacci series. This method should use a for-loop to guide the computation of the requested number. This method should have the signature below:

Please also write a method that gets an integer from the user. This should now be old hand:

Lastly, please construct a main() method as follows:

The Fibonacci Series

The Fibonacci Series is quite famous for its appearance in many biological, mathematical, and other systems. It is computed as follows:

Below is the beginning of the series:

Computing the values

To compute this in your program, you'll want to handle n=0 and n=1 as special cases and immediately return 1. For the subsequent numbers, you'll want to use a for loop to do the computation.

You should initialize variables nMinusOne and nMinusTwo, compute the next value, and then shift nMinusOne into nMinusTwo and then the newly computed value into nMinusOne. You should repeat this process until you've compued the nth value, as requested.

Submission

As usual...