Starting from:
$35

$29

Program #3 Solution

    1. Implementing data validation

    2. Implementing an accumulator

    3. Integer arithmetic

    4. Defining variables (integer and string)

    5. Using library procedures for I/O

    6. Implementing control structures (decision, loop)

Problem Definition

Write a MASM program to perform the following tasks:

Display the program title and programmer’s name.



Display instructions for the user


Repeatedly prompt the user to enter the number. Validate the user input to be in [-100, -1] (inclusive). Count and accumulate the valid user numbers until a non-negative number is entered (The non-negative number is discarded) Calculate the (rounded integer) average of the negative numbers

Display:


the number of negative numbers entered (Note: if no negative numbers were entered, display a special message and display the


goodbye message with the user's name at the end)

the sum of negative numbers entered


the average, rounded to the nearest integer (e.g., -20.5 rounds to -21)


a goodbye 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 main procedure must be modularized into commented logical sections (procedures are not required this time).

    3. Recursive solutions are not acceptable for this assignment. This one is about iteration.

    4. The program must be fully documented. This includes a complete header block for identification, description, etc., and a comment outline to explain each section of code.
    5. The lower limit must be defined and used as a constant.

    6. The usual requirements regarding documentation, readability, user-friendliness, etc., apply.

Notes

    1. There are no new concepts in this programming assignment. It is given for extra practice, to keep MASM fresh in your mind while we study internal/external data representation and error detection/correction.
    2. This is an integer program. Even though it would make more sense to use floating-point computations, you are required to do this one with integers.
Example Program Operation


Welcome to the Integer Accumulator by Austin Miller

What’s your name? Roger

Hello, Roger

Please enter numbers in [-100, -1].
Enter a non-negative number when you are finished to see results.

Enter number: -15

Enter number: -100

Enter number: -36

Enter number: -200
Invalid number, please enter numbers in [-100, -1].

Enter number: -10

Enter number: 0
You entered 4 valid numbers.

The sum of your valid numbers is -161

The rounded average is -40

Thank you for playing Integer Accumulator!

Goodbye, Roger.

Extra Credit Option (original definition must be fulfilled)
(1 pt) Calculate and display the average as a floating-point number, rounded to the nearest .001.


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 3 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



Full Marks
No Marks
TA and/or 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



Full Marks
No Marks
Identification Block


Documentation - Identification Block - Program Description
2 pts
0 pts



Description of functionality and purpose of program is included in



Full Marks
No Marks



identification block.






Documentation - Section Comments
4 pts
0 pts
Code section headers describe functionality and implementation of



Full Marks
No Marks
program flow. Should 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




Full Marks

No Marks
comments) but 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




Full Marks

No Marks
array. Greets user (e.g. "Hello, Username")






















Completeness - Displays Introduction
1 pts

0 pts
Displays program introduction. Program introduction should describe




Full Marks

No Marks
functionality of 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










Full Marks


No Marks



1 pts
identifiers for validation.






















Completeness - Validates User Data
4 pts

2 pts

0 pts

Validates that user-entered values are within the advertised limits.







Full

Partial validation

No



Marks

Validates only one end or neglects to check
Marks
4 pts





edge cases.

No










validation













Completeness - Displays Results (number of valid numbers, sum, and
4 pts


2 pts
0 pts



rounded average)









Full Marks

Partial Display
No Marks







4 pts
display a special message if no negative numbers were entered (-2 if










missed)






















Completeness - Displays Closing Message
1 pts



0 pts














1 pts


Full Marks


No Marks






































Correctness - Number of Valid Numbers
2 pts

1 pts


0 pts

Correct number of valid numbers is displayed.








Full

Incorrect for small numbers


No



Marks

Correct number of valid numbers for values

Marks
2 pts




greater than 2, but fails for one or more of the







following values (0, 1, 2)






























Criteria




Ratings


Pts











Correctness - Calculation of rounded average is correct
3 pts


2 pts


0 pts













Full Marks

Calculates average but not rounded
No Marks
3 pts






















Correctness - Calculation of Sum is correct
3 pts




0 pts













3 pts


Full Marks


No Marks














Requirements - Solution is non-recursive
1 pts




0 pts













1 pts


Full Marks


No Marks














Lower limit is defined and used as a constant
1 pts




0 pts













1 pts


Full Marks


No Marks














Requirements - Well-Modularized
4 pts




0 pts



Program is divided into logical sections, separated by Section Comment










Full Marks


No Marks


4 pts
blocks.









































Coding Style - Appropriately named identifiers
2 pts
1 pts




0 pts

Identifiers named so that a person reading the code can intuit the purpose









Full
Partial



No

of a variable, constant, or label just by reading its name.
Marks
Some identifiers are named well, with others

Marks
2 pts



having no relevance to their functionality.






















Criteria

Ratings

Pts







Coding Style - Readabilty
2 pts
1 pts

0 pts

Program uses readable white-space, indentation, and spacing as per the






Full
Marginally Readable

No

Indentation Style Guide. Logical sections are separated by white space.
Marks
Program is marginally readable but lacks proper
Marks
2 pts


alignment and white space.
















(1pt) Extra Credit for rounded average
0 pts


0 pts


Rounded average is rounded to the nearest .001.







Full Marks

No Marks

0 pts







Late Penalty
0 pts


0 pts


Remove points here for late assignments. (Enter negative point value, 15%







Full Marks

No Marks

0 pts
of 'earned' points per day late)














Total Points: 50

More products