$29
Objectives
1. Getting string input
2. Designing and implementing a counted loop
3. Designing and implementing a post-test loop
4. Keeping track of a previous value
5. Implementing data validation
Problem Definition
Write a program to calculate Fibonacci numbers.
Display the program title and programmer’s name. Then prompt the user for their name and greet them (by name).
Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46].
Calculate and display all of the Fibonacci numbers up to and including the nth term. The results should be displayed 4 terms per line with at least 5 spaces between terms.
Display a parting message that includes the user’s name, and terminate the program.
Requirements
1. The programmer’s name and the user’s name must appear in the output.
2. The loop that implements data validation must be implemented as a post-test loop.
3. The loop that calculates the Fibonacci terms must be implemented using the MASM loop instruction.
4. Numeric user input must be aquired using the ReadInt Irvine procedure (as a signed integer).
5. The main procedure must be modularized into at least the following sections (procedures are not required in this program):
introduction
displayInstructions
getUserInfo
displayFibs
goodbye
6. Note that each of the above sections (introduction, displayInstructions, getUserInfo, etc) needs to have a header block explaining its purpose.
7. Recursive solutions are not acceptable for this assignment. This one is about iteration.
8. The upper limit must be defined and used as a constant.
9. The usual requirements regarding documentation, readability, user-friendliness, etc., apply.
Notes
1. It is not necessary to store the Fibonacci numbers in an array. The terms may be displayed as they are generated.
2. The second-order Fibonacci sequence is defined as:
1. The first two terms are both 1.
2. All other terms are calculated as the sum of the two previous terms.
3. The reason for restricting n to [1 .. 46] is that the 47th Fibonacci number is too big for DWORD data type.
Example Program Operation
Fibonacci Numbers
Programmed by Leonardo Pisano
What’s your name? Paul
Hello, Paul
Enter the number of Fibonacci terms to be displayed.
Provide the number as an integer in the range [1 .. 46].
How many Fibonacci terms do you want? 50
Out of range. Enter a number in [1 .. 46]
How many Fibonacci terms do you want? -6
Out of range. Enter a number in [1 ..
46]
How many Fibonacci terms do you want?
14
1
1
2
3
5
8
13
21
34
55
89
144
233
377
Results certified by Leonardo Pisano.
Goodbye, Paul.
Extra Credit Option (original definition must be fulfilled)
(1 pt) Display the numbers in aligned columns.
Remember, in order to ensure you receive credit for any extra credit work, you must add one print statement to your program output PER EXTRA CREDIT which describes the extra credit you chose to work on. You will not receive extra credit points unless you do this. The statement must be formatted as follows...
--Program Intro--
**EC: DESCRIPTION
--Program prompts, etc--
Please refer back to the documentation for Program 1 to see a sample of the extra credit format.
Program 2 Rubric
Criteria
Ratings
Files Correctly Submitted
1 pts
0 pts
Submitted file is correct assignment and is an individual .asm file.
Full Marks
No Marks
Program Assembles & Links
2 pts
0 pts
Submitted program assembles and links without need for clarifying work for TA and/or
Full Marks
No Marks
messages to the student.
This assumes the program is actually an attempt at the assignment. Non-attempts which
compile/link earn no points.
Documentation - Identification Block - Header
1 pts
0 pts
Name, Date, Program number, etc as per syllabus are included in Identification Block
Full Marks
No Marks
Documentation - Identification Block - Program Description
2 pts
0 pts
Description of functionality and purpose of program is included in identification block.
Full Marks
No Marks
Documentation - Section Comments
4 pts
0 pts
Code section headers describe functionality and implementation of program flow. Should
Full Marks
No Marks
mirror the style guide image.
Pts
• pts
2 pts
• pts
2 pts
4 pts
Criteria
Ratings
Documentation - In-line Comments
1 pts
0 pts
In-line comments contribute to understanding of program flow (from section comments) but
Full Marks
No Marks
are not line-by-line descriptions of moving memory to registers.
Verification - Program Executes
5 pts
0 pts
Program executes and makes some attempt at the assigned functionality.
Full Marks
No Marks
Completeness - Displays Programmer Name
1 pts
0 pts
Program prints out the programmer's name.
Full Marks
No Marks
Completeness - Gets / Uses User's name
2 pts
0 pts
Receives input with ReadString. Saves input in a null-terminated BYTE array. Greets user
Full Marks
No Marks
(e.g. "Hello, Username")
Completeness - Displays Introduction
1 pts
0 pts
Displays program introduction. Program introduction should describe functionality of
Full Marks
No Marks
program.
Completeness - Prompt for Input
2 pts
0 pts
Prompts user to enter data, specifying bounds of acceptable inputs.
Full Marks
No Marks
Pts
1 pts
• pts
1 pts
2 pts
• pts
2 pts
Criteria
Ratings
Pts
Completeness - Gets data from user
1 pts
0 pts
Utilizes ReadInt to receive user input. Saves values in appropriately-named identifiers for
Full Marks
No Marks
1 pts
validation.
Completeness - Validates User Data
3 pts
2 pts
0 pts
Validates that user-entered values are within the advertised limits. Negative values are
Full
Partial validation
No
rejected.
Marks
Validates only one end or
Marks
3 pts
neglects to check edge cases.
No
validation
Completeness - Displays Results
2 pts
0 pts
2 pts
Full Marks
No Marks
Completeness - Displays Closing Message
1 pts
0 pts
1 pts
Full Marks
No Marks
Correctness - Number of Terms
2 pts
1 pts
0 pts
Correct number of terms are displayed.
Full
Incorrect for small numbers
No
Marks
Correct number of terms for
Marks
2 pts
values greater than 3, but fails for
one or more of the following
values (1, 2, 3)
Correctness - Calculations are Correct
2 pts
0 pts
2 pts
Full Marks
No Marks
Criteria
Ratings
Correctness - Numbers displayed 4 per line
2 pts
0 pts
Numbers are displayed 4 per line on sufficiently large console window width. There should
Full Marks
No Marks
be at least 5 spaces between each term. No points granted for implementations that
require console window be a specific size to work.
Correctness - Partial lines displayed correctly
1 pts
0 pts
Full Marks
No Marks
Requirements - Solution is non-recursive
1 pts
0 pts
Full Marks
No Marks
Upper limit is defined and used as a constant
1 pts
0 pts
Full Marks
No Marks
Requirements
- Well-Modularized
4 pts
0 pts
Program is divided into logical sections, separated by Section Comment blocks.
Full Marks
No Marks
Requirements - Counted loop implemented with LOOP instruction
2 pts
0 pts
Full Marks
No Marks
Requirements - Data validation loop is post-test loop
2 pts
0 pts
Full Marks
No Marks
Pts
2 pts
• pts
• pts
• pts
4 pts
• pts
• pts
Criteria
Ratings
Pts
Coding Style - Appropriately named identifiers
2 pts
1 pts
0 pts
Identifiers named so that a person reading the code can intuit the purpose of a variable,
Full
Partial
No
constant, or label just by reading its name.
Marks
Some identifiers are named well,
Marks
2 pts
with others having no relevance to
their functionality.
Coding Style - Readabilty
2 pts
1 pts
0 pts
Program uses readable white-space, indentation, and spacing as per the Indentation Style
Full
Marginally Readable
No
Guide. Logical sections are separated by white space.
Marks
Program is marginally readable
Marks
2 pts
but lacks proper alignment and
white space.
(1pt) Extra Credit for columns
0 pts
0 pts
Fibonacci numbers are displayed in aligned columns.
0 pts
Full Marks
No Marks
Late
Penalty
0 pts
0 pts
Remove points here for late assignments. (Enter negative point value, 15% of 'earned'
Full Marks
No Marks
0 pts
points per day late)
Total Points: 50