Assignment 5

  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Assignment 5 as PDF for free.

More details

  • Words: 331
  • Pages: 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 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

Related Documents

Assignment 5
August 2019 28
Assignment 5
April 2020 10
Assignment 5
June 2020 7
Assignment 5
April 2020 20
Assignment 5
June 2020 5
Assignment#5
May 2020 11