Part A (20 points)

Implement Exercise 3 on Page 112 of your text, which says:

The Fibonacci numbers are a sequence of integers in which the first two elements are 1, and each following element is the sum of the two preceding elements.  The mathematical definition of each kth Fibonacci number is the following:

F(k)

• F(k-1) + F(k-2), k > 2
• 1, k <= 2

The first twelve Fibonacci numbers are:

1 1 2 3 5 8 13 21 34 55 89 144

Details

• Write a for loop that computes and prints the Fibonacci numbers, one per line, based on a command line argument to your program (NOTE: this is an additional specification that is not required by your text).  The number specified on the command line is guaranteed to be an integer that is greater than 0.
• Place the code to compute and print the Fibonacci numbers in an appropriately named method.  This method should have a single parameter of type int which is the value specified via the command line argument.
• Name your source file Fibonacci.java.
• Include a comment at the top of your code that includes your name, the date, a description of the class, and any shortcomings your program has.  NOTE: any code you submit should always have these items at the top in a comment.

Part B (20 points)

Implement Programming Project 4 on page 115 of your text which states:

Write a program that produces the following output.  Use a class constant to make it possible to change the number of stairs in the figure.

o  *******
/|\ *     *
/ \ *     *
o  ******     *
/|\ *          *
/ \ *          *
o  ******          *
/|\ *               *
/ \ *               *
o  ******               *
/|\ *                    *
/ \ *                    *
o  ******                    *
/|\ *                         *
/ \ *                         *
********************************

Details

• You must employ for loops -- see section 2.5 of your text for some ideas.  You will almost certainly need nested for loops, however this may be indirect as you could call a method that contains a for loop from inside a for loop in another method.
• Employ methods for specific tasks as you deem necessary to promote code reuse (perhaps printHead, printTorso, printLegs methods, among others) .  As with Assignment 1, try not to print the exact same thing twice in different println statements.
• NOTE: it is permissible (but not required) to pass parameters to your methods if you wish -- this could serve to further simplify your code.
• Name your source file Stairs.java.
• Include a comment at the top of your code that includes your name, the date, a description of the class, and any shortcomings your program has.

TO TURN IN

Submit to blackboard a .zip file that contains your Java source files (Fibonocci.java and Stairs.java) and the .class file produced from compilation.  Also include a capture of the output produced from running each of your programs.  This output should be placed in a text file named Fibonocci.txt and Stairs.txt, respectively.  Include at least three runs of the Fibonacci program using different command line arguments.  Include two different runs of Stairs -- one with a constant value of 5 and one with a constant value of 1.  Name your zip with your last name, followed by the first initial of your first name, followed by hw2 (ex: capaulthw2.zip).