You are on page 1of 3

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 Number 0-1000 The number of pumpkins.
pumpkinweight Number 0-600 The weight of the pumpkin.
maxpumpkinweight Number 0-600 The maximum pumpkin weight.
pumpkintotal Number 10000 The total weight of all pumpkins.
pumpkinaverage Number 0-600 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

WRITE “No weights pumpkinaverage


to read” = 0

pumpkintotal
= 0

maxpumpkinweigh
t = 0

count
= 0

N
count <
numpumpkins

pumpkinaverage =
pumpkintotal / count = count + 1
numpumpkins

WRITE “The
heaviest pumpkin WRITE “Enter
is “, pumpkin weight”
maxpumpkinweight
WRITE “The
average pumpkin READ
weight is “, pumpkinweight
pumpkinaverage

WRITE “Weight “,
pumpkinweight,
“ recorded”

Y N

pumpkinweight
>
maxpumpkinweig

maxpumpkinweight =
pumpkinweight

pumpkintotal =
pumpkintotal +
pumpkinweight

STOP