CPSC 231: Assignment 3 (Due Monday Oct. 21)
Weighting = 3%
The Fibonacci numbers are a sequence of numbers that was developed by the European mathematician Leonardo of Pisa for biological simulations. The first two numbers in sequence are both one. All other numbers in this sequence are calculated as the sum of the previous two numbers i.e.,
f (0) = 1
f (1) = 1
f (2) = f (1) + f (0) = 1 + 1 = 2
f (3) = f (2) + f (1) = 2 + 1 = 3
f (4) = f (3) + f (2) = 3 + 2 = 5
f (5) = f (4) + f (3) = 5 + 3 = 8
f (6) = f (5) + f (4) = 8 + 5 = 13
f (7) = f (6) + f (5) = 13 + 8 = 21
f (8) = f (7) + f (6) = 21 + 13 = 34
f (9) + f (8) + f (7) = 34 + 21 = 55
f (10) = f (9) + f (8) = 55 + 34 = 89
: : :
f (n) = f (n-1) + f (n-2) for n = 2, 3, 4 ...
For this assignment you are to write a program that calculates Fibonacci numbers from n = 0 up to and including n = 45. The value for n will be entered by the user of the program. You are to implement your assignment with an iterative solution that employs looping and decision making constructs. You are not to submit a recursive solution for this assignment.
Grading
B+ Version
For any number entered by the user from one up to some arbitrary nth value (maximum of 45), your program will calculate the final Fibonacci number in that sequence. For example, if the user of the program entered six, the program would show the result for f(6) which is thirteen. A sample solution that implements a B+ solution can be found under the path: /home/231/assignments/assignment3/Bplus.
A+ Version
Your program will not only calculate the Fibonacci number for any value from one up to some arbitrary nth value (maximum of 45), your program will not only show the last Fibonacci number, but will also show intermediate values. For example, if the person using the program typed in six then the program would show all the Fibonacci numbers from zero to six. A program that implements an A+ solution can be found under the path: /home/231/assignments/assignment3/Aplus.
Requirements for both versions
Minor requirements
Both versions of your assignment must fulfill the following minor requirements. Failure to satisfactorily meet each minor requirement will result in the loss of one letter "step" (e.g., "A+" to "A", "A" to "A-" etc.)
Major requirement
Both versions of your assignment must also be accompanied by a either a flowchart or pseudo-code that correctly specifies the algorithm for your solution. Failure to include to include the algorithm will result in the loss of a letter grade (e.g., "A+" to "B+", "B+" to "C+"). It is highly recommended that you layout the algorithm on paper prior to writing your program.
Learning how to apply the concepts of structured programming, decision-making and repetition, in a Pascal program.
There are two major steps to submitting this assignment:
Use the submit system to electronically submit the source code for your assignment (i.e., the *.p file). In addition you must also submit a text file called "README" for your TA. This file will provide step-by-step instructions for running your program, as well what version of the assignment you have completed and any special cases or conditions that you may have implemented in addition to the requirements of the basic assignment. It must be clear and complete enough so that your TA will know how to mark your assignment (don't expect them to have to decipher cryptic instructions).
Print out the source code for your assignment (print the source code directly rather than running a script and then printing the script) and put the source code stapled with your hand drawn/hand written algorithm into the appropriate drop box located on the second floor of Math Sciences.