# 9 draw the hierarchy chart and design the logic for a

• Homework Help
• jackdikici
• 16
• 100% (3) 3 out of 3 people found this document helpful

This preview shows page 14 - 16 out of 16 pages.

9. Draw the hierarchy chart and design the logic for a program for the manager of the Jeter County softball team, who wants to compute batting averages for his players. A batting average is computed as hits divided by at-bats, and is usually expressed to three decimal positions (for example, .235). Design a program that prompts the user for a player jersey number, the number of hits, and the number of at-bats, and then displays all the data, including the calculated batting average. The program accepts players continuously until 0 is entered for the jersey number. Use appropriate modules, including one that displays “End of job” after the sentinel is entered for the jersey number.
Programming Logic and Design, 6e Solutions 2-15 Pseudocode: start Declarations num jerseyNumber num numOfHits num numOfAtBats num battingAvg string NUM_PROMPT = “Enter the player’s jersey number” string HITS_PROMPT = “Enter the number of hits” string BATS_PROMPT = “Enter the number of at bats” string END_LINE = “End of job” housekeeping() while not (jerseyNumber = 0) detailLoop() endwhile endOfJob() stop housekeeping() output NUM_PROMPT input jerseyNumber
Programming Logic and Design, 6e Solutions 2-16 return detailLoop() output HITS_PROMPT input numOfHits output BATS_PROMPT input numOfAtBats battingAvg = numOfHits / numOfAtBats output battingAvg output NUM_PROMPT input jerseyNumber return endOfJob() output END_LINE return