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 9

Due in Lab 8, Week 10.

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 a program called percent that helps calculate the ``To Date %'' columns of your PSP Project Plan Summary.

The program shall operate as follows: It shall prompt for a list of integers from the standard input, one per line, terminated by a blank line (just as for Homework 3 and Homework 5). It shall then calculate the total of those numbers and the percentage of that total that each represents. It shall present the output as a table, with two columns separated by exactly four spaces. The left column shall contain the original number, right-justified in a field of width four characters. The right colum shall contain the percentages, followed by a `%' symbol, right justified in a field of width six characters (up to three digits before the decimal point, the decimal point, one figure after the decimal point, and the percent symbol). Percentages shall be rounded to one decimal place.

For example (the To Date Time in Phase and the To Date Defects Injected from my Homework 7):

comp2100@iwaki percent
> 47
> 37
> 81
> 21
> 66
> 57
>

  47     15.2%
  37     12.0%
  81     26.2%
  21      6.8%
  66     21.4%
  57     18.4%
 309
comp2100@iwaki percent
> 2
> 17
> 1
> 3
>

   2      8.7%
  17     73.9%
   1      4.3%
   3     13.0%
  23

Notice that there is a blank line between the prompt for the last line of input and the start of the output. Notice also that the last line of output holds the total of all the inputs, but no percentage.

If there are no numbers input, or if their total is zero, the program should print an error message and stop (rather than trying to divide by zero). If one of the inputs is not an integer, it should print an error message and prompt for it again (just as in Homeworks 3 and 5).


PSP Note

If you re-use code from Homework 3 or 5, you should not count those lines as part of the new and changed lines of code for this program.


Hints

I think it might make sense to use your solution to Homework 3 as the starting point, and modify that program. You can then use diff to work out the new and changed lines of code just as you did for the last two homeworks.

Look up the feature to_string_format of class DOUBLE. You will need to figure out the length of this string before you print it, so that you can get the spacing right.


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.2, 10 May 2004, 12:47:44