McCoy, Daniel CISP-300 Assignment 5 Statement of Problem Construct a program flowchart and corresponding pseudocode to solve the following problem: You are in a pumpkin patch looking for the great pumpkin. The first input record indicates how many pumpkin weights follow. Several input records, each containing the weight of a pumpkin, follow the input record. Assume that all the pumpkin weights are greater than 0. You are to find the largest weight, and the average weight of the pumpkins. Include an initial IF in your design that will output a descriptive message if the header record indicates that there are no input records to process. Table of Variables Name
Type
Range
Description
numpumpkins pumpkinweight
Number Number
0-1000 0-600
The number of pumpkins. The weight of the pumpkin.
maxpumpkinweight
Number
0-600
The maximum pumpkin weight.
pumpkintotal pumpkinaverage
Number Number
10000 0-600
The total weight of all pumpkins. The average pumpkin weight.
Pseudo Code START WRITE "How many weights to enter?" READ numpumpkins IF numpumpkins == 0 THEN WRITE "No weights to record" ELSE pumpkinaverage = 0 pumpkintotal = 0 maxpumpkinweight = 0 count = 0 DOWHILE count < numpumpkins count = count + 1 WRITE "Enter pumpkin weight" READ pumpkinweight WRITE "Weight ", pumpkinweight, " recorded" IF pumpkinweight > maxpumpkinweight THEN maxpumpkinweight = pumpkinweight ELSE ENDIF pumpkintotal = pumpkintotal + pumpkinweight ENDDO pumpkinaverage = pumpkintotal / numpumpkins WRITE "The heaviest pumpkin is ", maxpumpkinweight WRITE "The average pumpkin weight is ", pumpkinaverage ENDIF STOP
START
WRITE “How many weights to enter?”
READ numpumpkins Y
N numpumpkins == 0
pumpkinaverage = 0
WRITE “No weights to read”
pumpkintotal = 0
maxpumpkinweigh t = 0
count = 0
N count < numpumpkins
Y
pumpkinaverage = pumpkintotal / numpumpkins
WRITE “The heaviest pumpkin is “, maxpumpkinweight
count = count + 1
WRITE “Enter pumpkin weight”
WRITE “The average pumpkin weight is “, pumpkinaverage
READ pumpkinweight
WRITE “Weight “, pumpkinweight, “ recorded”
N
Y pumpkinweight > maxpumpkinweig
maxpumpkinweight = pumpkinweight
pumpkintotal = pumpkintotal + pumpkinweight
STOP