ASSIGNMENT 2
Code reuse: methods, variables and loops
40 points
Due on Blackboard by 11:59:59pm Friday, April 16


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)

The first twelve Fibonacci numbers are:

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

Details


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


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).