COSC
117
Programming Assignment #2
DESCRIPTION: Produce a list of the quantity of 4 different crab sizes.
The program will interactively read individual crab sizes until a
negative size is received.
(Negative number is the sentinel data). Crabs
5.0 up to 5.5 (but not including 5.5 inches are small, 5.5 up to 6.0(but not
including 6.0) are medium and crabs 6.0 and over are large.
Any crab less than 5 inches must be thrown back as non-legal.
The output will consist of the total number of crabs and the quantity in
each of the four categories: illegal, small, medium, large.
It will also display the average size of all crabs and the average size
of all legal crabs.
CLARIFICATION: The input of this program is interactive (received from the
keyboard by the person running the program).
Floating point output must be rounded to 2 places to the right of the
decimal point.
Details of implementation: You must
use several methods and functions in this program.
Main program: This will print out
what the program does and then calls a method called findCrab() that will read
in the crab size and keep track of the amount of crabs in each of the
categories. If will keep a running
total of the sizes of all the crabs as well as just the legal crabs.
It will then call a function to find the average size of all crabs as well as
the average size of just the legal crabs.
It will then call a method that will print out all the information. (All output
will be done in this method except for the introduction comments printed in the
main method).
SAMPLE INPUT:
5.7
5.2
6.0
3.5
5.4
5.5
5.9
7.2
4.8
5.0
-1
SAMPLE OUTPUT:
This
program will produce a list of the quantity of 4 different crab sizes.
The program
will interactively read the crab sizes until a negative size is received.
The
categories are large, medium, small and illegal.
The output
will consist of the total number of crabs and the quantity in each size
It will
also display the average size of all crabs and the average of all legal crabs
Please
input a crab size, input a negative number to stop 5.7
Please
input a crab size, input a negative number to stop
5.2
Please
input a crab size, input a negative number to stop
6
Please
input a crab size, input a negative number to stop
3.5
Please
input a crab size, input a negative number to stop
5.4
Please
input a crab size, input a negative number to stop
5.5
Please
input a crab size, input a negative number to stop
5.9
Please
input a crab size, input a negative number to stop
7.2
Please
input a crab size, input a negative number to stop
4.8
Please
input a crab size, input a negative number to stop
5
Please
input a crab size, input a negative number to stop
-1
The number
of illegal crabs = 2
The number
of small crabs = 3
The number
of medium crabs = 3
The number
of large crabs = 2
The average
size of legal crabs = 5.74
The average
size of all crabs = 5.42
I.
You must develop an Algorithm that includes the following.
A.
Description and Clarification
B.
Sample Input/Output.
The specs
give you one sample I/O. You should
include at least 1 more
C.
Variable List
1.
Input Variables
2.
Output Variables
3.
Other Variables
D.
A Tree Structure
E.
The algorithm coming from the tree structure.
It should use generic language
II.
You must write the program so that it runs properly.
A.
Heading comments
1.
Programmers name
2.
Assignment number
3.
Class and Section
4.
Date
5.
Description of the program including input and output.
Constant and variable declarations (tell what each do)
D.
Body of the program that is well documented with appropriate comments
about the logic of the program.