Chocolate Bar Weights

OVERVIEW

The quality control department at Cadbury chocolates is responsible for ensuring that the chocolate bars produced have consistent weights. To do this, the quality engineers take a random sample of bars from each production run and weigh them.  You have been hired to write a program to analyze the data and create a summary report that the QC department can use to assess product quality.

INPUT REQUIREMENTS

Data for a series of production runs, one item per line:

1.1 Production Run ID (positive integer between 1000 and 9999)

1.2 Desired weight in grams (float)

1.3 Candy bar weights in grams (float). A sentinel value of zero indicates the last weight for this run.

OUTPUT REQUIREMENTS

For each run, display

2.1 The Run ID

2.2 The number of weights processed.

2.3 The number of rejects.

2.4 The percent rejects.

2.5 The average difference from the desired weight.

2.6 A warning message if the percent rejects is greater than ten.

A summary of

2.7 The Run ID of the run with the largest reject percentage.

2.8 The percent rejected of the run with the largest number of rejects.

2.9 The total number of weights processed.

FUNCTIONAL REQUIREMENTS

3.1 Open standard input for reading the data.

3.2 Read the Run ID and desired weight.

3.3 Read each candy bar weight and count # bars for run, and total.

3.4 Compute difference from desired weight and add to total difference.

3.5 Reject any bar whose difference is greater than 5% of desired weight.

3.6 Terminate the application if any weight is greater than 999.

3.7 Count the number of rejects for the run.

3.8 End the run when a sentinel value of zero is read.

3.9 Compute the average difference from desired weight.

3.10 Compute the percent rejects

3.11 Display a warning if percentage of rejects is greater than ten.

3.12 Determine Run ID of run with largest reject percentage.

3.13 Determine percent rejected of the run with the largest number of rejects.

3.14 Count the total number of bars processed.

SAMPLE OUTPUT

			Chocolate Bar Weights Analysis

RUN ID # bars in run # rejects % rejects Avg difference

1002 50 0 0 0.12
1123 51 2 0.04 0.15
1221 57 7 0.12 0.08 WARNING!
1017 52 3 0.05 0.19

Largest reject percentage was run XX with YY percent.
Total # of bars processed: ZZ

The spacing between columns is not important, but each column should be
aligned under the header as shown.