COMP2100/2500 Software Construction
Paced programming exercises — Homework

Weekly homework is an important part of learning and self-development in the COMP2100/2500 Software Construction courses. The homework exercises are not given any assessment marks. However before you decide that you will save time by not doing the homework, consider this:

We guarantee that one of the homework exercises (in a slightly modified form) will be repeated on the final examination test. If you will have not done it, you find yourself at a serious disadvantage, in a time-pressure situation.

Clearly you are free to collaborate on the homework exercises as much as you like. My recommendation, however, would be to make a serious effort to do the homework by yourself. A good idea would be to set aside a particular time each week for homework. Then when you have completed it, you could get extra value from it by comparing your solution with other students and discussing the differences. There is almost no benefit from looking for other people's solutions (or my sample solutions, if available) before trying it seriously yourself: you just cannot improve your programming skills that way.

Aims

  1. To provide you with an opportunity and an incentive to do regular programming, thus improving your skills.

  2. To provide an opportunity for you to learn and practice the PSP.

  3. To help you practise the use of version control every time you code, so it can be as natural as breathing.

The initial aim some years ago was just #2 above: practise PSP. The idea was that there is little point in doing the PSP on challenging programming tasks that cover completely new ground for you. While you are learning new skills there is no point in recording your time and trying to learn something from the statistics. You have a much better chance of learning something from the PSP while carrying out routine programming tasks — ones that aren't a major challenge involving new concepts and techniques. The idea is that the homework programs should be relatively straightforward. Your challenge is to write them well, in a reasonable time, with as few defects as possible and to learn to predict your own process.

But it is also true that in 2002—2007 many students found that doing the homework tasks helped them to improve their programming skills quite dramatically. What we had expected to be easy tasks turned out to be rather difficult at first for many students, but by mid-way through the semester their skills had improved to the point where they were much more confident and capable programmers. If you are weak in Java programming at the start of the semester, look at these weekly programming exercises as an opportunity to turn that weakness into a strength.

The exercises

Here are the homework exercises, some estimate of size of the solution, and recommended test methods (in some cases).

link to specification brief description estimated size:
total lines/ NCNB[1] lines
classes/ methods test method

Homework 1.

Character table. 48 / 341 class / 2 methodscompare table of characters by eye
Homework 2.TBC Factors
Homework 3.TBC Arithmetic mean
Homework 4.TBC Quadratic equation roots

Homework 5.

Counting logical lines of code. 104/ 651 class / 4 methodsTest cases: use any (small) Java source files, count by hand.
Or use the example files in directory http://cs/student/comp2100/homeworks/hw05 with counts as shown here
AttributeList.java97
XmlContainerElement.java 176
XmlDataElement.java44
XmlElement.java47

Homework 6.

Writing numbers out in words, part I (small numbers). 101 / 701 class / 2 methods
three digits: java NumbersToWords 346three hundred and forty-six
two digits: java NumbersToWords 46forty-six
one digit: java NumbersToWords 3three
outside boundary: (low): java NumbersToWords 0error message
inside boundary: (low): java NumbersToWords 1one
outside boundary (high): java NumbersToWords 1000error message
inside boundary (high): java NumbersToWords 999nine hundred and ninety-nine
spelling of "forty": java NumbersToWords 42forty-two

Homework 7.

Writing numbers out in words, part II (big numbers). 142 / 1111 class / 3 methods lower boundary is as above. Upper boundary is determined by representation of Integer on your system.
Equivalence class tests: a set of 7 numbers with length 1, 2 (simple), 2 (composite), 3, 4, 7 and 10 digits.
length 1 digitjava Words 7seven
length 2 digits (teens)java Words 17seventeen
length 2 digits (composite)java Words 27twenty-seven
length 3 digitsjava Words 347three hundred and forty-seven
length 4 digitsjava Words 1234 one thousand, two hundred and thirty-four
length 7 digitsjava Words 1234567one million, two hundred and thirty-four thousand, five hundred and sixty-seven
length 10 digitsjava Words 1234567891one billion, two hundred and thirty-four million, five hundred and sixty-seven thousand, eight hundred and ninety-one
Suggested tasks for homeworks 8, 9, 10 may change - watch for changes here.  

Homework 8.

Writing numbers out in words, part III (writing cheques).

Homework 9.

Expressing each number in a list as a percentage of the total.

Homework 10.

Making change. (How many of each type of coin do you need to make a particular amount?)

Homework 11.

Sorting integers using a binary search tree. tbatbatba

Homework 12.

Finding the five commonest words in a text file. 373 / 296 (I wrote my own version of Binary Tree) 3 classes / 12 methods You can test against an alternative implementation - a shell script commonestFive.sh and compare the outputs on any text inputs (Note: this script does not sort equally frequent words into alphabetical order, as required in the homework specification).
Equivalence cases? boundary cases? hmmm...

Notes and references

  1. NCNB: "non-comment, non-blank" - an indication of the actual code size of a source program file, counting the lines which are not comments and not blank. If the program has a standard layout of statements and other constructs this is a fair measure of comparable size. NCNB gives a smaller count than is measured by LineCount (homework-05) because it excludes all comments.
____________________________________________________

Copyright © 2006, 2008 Ian Barnes, Chris Johnson, The Australian National University
$Revision: 1.12 $ $Date: 2008/02/27 02:58:20 $
Feedback & Queries to comp2100@cs.anu.edu.au