[Homework 1] [Homework 2] [Homework 3] [Homework 4] [Homework 5] [Homework 6] [Homework 7] [Homework 8] [Homework 9] [Homework 10] [Homework 11] [Homework 12]![]()
COMP2100
Homework 3Due in Lab 3, Week 4.
Write the following program, following the initial PSP and filling in the Project Plan Summary and a Defect Recording Log.
For the planned Total New and Changed lines of code make an estimate. At this stage it will be little better than a guess, but part of what we're trying to develop is the quality of those guesses. Of course you'll need to read the requirements below carefully before making your guess.
Use the `To Date' and `To Date %' figures from the form you filled in in Lab 2 when you complete the `Plan' column.
Write a program to count and calculate the average (or arithmetic mean) of a list of integers. Here is a sample interaction with the program:
[comp2100@karajan]$ average Please enter data values, one per line. > 1 > two Invalid input, try again. > 2 > 2 > Here is that data again: 1 2 2 N = 3 Mean = 1.67The program must prompt for each data value by printing the string "> " at the start of a line. It must read one line of input at a time. If the line is a valid integer, it must add it to the list, otherwise it must ask the user to try again. Data entry is terminated by an empty line. The formula for the mean m of the numbers x1 ... xN is
m = (x1 + ... + xN) / N
The calculated mean should be of class DOUBLE, and should be rounded to two decimal places.
Hints
In order to complete this program, you will probably need to consult the short forms of the library classes ARRAY, INTEGER, DOUBLE, STRING and STD_INPUT_OUTPUT. You can do this from the command line by typing for example `short double'. If there's too much for you to read, it might help to use less, by typing `short double | less'. Remember that you can tell if a string is empty by calling the is_empty query on it.
To print a DOUBLE rounded to two decimal places, use put_double_format in class STD_INPUT_OUTPUT. Note that the internal documentation is wrong, the command io.put_double_format (3.519,2) prints 3.52 not 3.51. (At least, it did on my home computer when I first wrote these notes two years ago. Try it for yourself and see. You can't always trust documentation.)
Test your program with various inputs including the data from the example above, until you are sure that it is correct. Don't forget to try an empty data set. (Sure enough, my first version crashed on a data set with zero elements.) What other bad data can you think of?
Defect Type Table
Here is the table of defect types that you need to use when filling in the `Type' column of your Defect Recording Log.
Type Number Type Name Description 10 Documentation comments, messages 20 Syntax spelling, punctuation, typos, instruction formats, missing reserved words, symbols, sections... 30 Build, package change management, version control, compiling the wrong version of a file 40 Assignment declaration, duplicate names, scope 50 Interface procedure and function calls, wrong types or numbers of arguments, wrong feature name, wrong class, input/output, user formats 60 Checking error messages, inadequate checks, wrong pre- and post-conditions 70 Data structure, content 80 Function logic errors, loops, recursion, computation, function defects - these are the real algorithmic mistakes 90 System configuration, timing, memory - you shouldn't see many of these at this stage 100 Environment design, compile, test and other support systems - you shouldn't see many of these either, although perhaps things like having your program work at home but not in the lab might fit here This table is based on Table 12.1 on page 141 of Introduction to the Personal Software Process by Watts Humphrey (Addison-Wesley, 1997).
Deliverables
To get your mark, you must attend your registered lab group with:
A completed Time Log for the past week.
A completed Weekly Time Use Summary for the past week.
A printout of your completed program.
A completed Initial PSP Project Plan Summary covering the development of the program.
A completed Defect Recording Log with details of all defects found during the development.
[Homework 1] [Homework 2] [Homework 3] [Homework 4] [Homework 5] [Homework 6] [Homework 7] [Homework 8] [Homework 9] [Homework 10] [Homework 11] [Homework 12]![]()
Copyright © 2004, Ian Barnes, The Australian National University
Feedback & Queries to
comp2100@iwaki.anu.edu.au
Version 2004.1, 11 March 2004, 13:17:21