ANU The Australian National University
____________________________________________________
[ANU] [DCS] [COMP2100] [Description] [Schedule] [Lectures] [Labs] [Homework] [Assignments] [Assessment] [PSP] [Eiffel] [Reading] [Help]
____________________________________________________
____________________________________________________
[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 10

Due in Lab 9, Week 11.

Continue filling in a new Time Recording Log and Weekly Time Use Summary each week.

Write the following program, following the enhanced PSP as described in Lecture 19 and filling in the Project Plan Summary and a Defect Recording Log. Use one of the Project Plan Summary forms that doesn't have greyed-out sections.

Write an Eiffel program called `change' that works out how to make change in coins for a given number of cents.

The program shall take exactly one command line argument, which should be a non-negative integer in the range 3-497. If the argument is out of range, the program should print an error message and stop.

If the argument is not a multiple of 5, the program shall first round it to the nearest multiple of 5.

The different types of coins you may use for making change are 5c, 10c, 20c, 50c, $1 and $2.

The program shall use a `greedy' algorithm to choose between the many possible ways to make change. That is, it shall first use as many $2 coins as it can, then as many $1 coins as it can, then as many 50c pieces and so on.

For example:

comp2100@iwaki change 20
20c = 1 x 20c
comp2100@iwaki change 85
85c = 1 x 50c + 1 x 20c + 1 x 10c + 1 x 5c
comp2100@iwaki change 90
90c = 1 x 50c + 2 x 20c
comp2100@iwaki change 497
$4.95 = 2 x $2 + 1 x 50c + 2 x 20c + 1 x 5c
comp2100@iwaki change 498
Error: argument 498 is too large.

Output should be formatted exactly as in the examples above.


Hints

Looks to me like you'll either need nested loops or recursion, or perhaps just one loop and some clever use of \\ and //. If I were you I'd probably store the values of the coins in order in an array.


Deliverables

To get your mark, you must attend your registered lab group with your lab notebook containing:

  1. A completed Time Log for the past week.

  2. A completed Weekly Time Use Summary for the past week.

  3. A printout of your completed program.

  4. A completed PSP Project Plan Summary covering the development of the program, and including a Code Review phase, defect densities, defect injection and removal rates and process yield. Calculating the A/FR is optional, but recommended.

  5. A completed Defect Recording Log with details of all defects found during the development.

  6. A completed Code Review checklist.

These must all be securely located in your notebook: either stuck or stapled into a standard notebook, or punched and stored in a ring binder. No loose sheets!

____________________________________________________
[Homework 1] [Homework 2] [Homework 3] [Homework 4] [Homework 5] [Homework 6] [Homework 7] [Homework 8] [Homework 9] [Homework 10] [Homework 11] [Homework 12]
____________________________________________________
____________________________________________________
[ANU] [DCS] [COMP2100] [Description] [Schedule] [Lectures] [Labs] [Homework] [Assignments] [Assessment] [PSP] [Eiffel] [Reading] [Help]
____________________________________________________

Copyright © 2004, Ian Barnes, The Australian National University
Feedback & Queries to comp2100@iwaki.anu.edu.au
Version 2004.1, 10 May 2004, 10:30:40