Jobcost numhours laborcost materialscost

This preview shows page 20 - 26 out of 35 pages.

jobCost = (numHours * LABOR_COST) + (materialsCost * MATERIAL_INCREASE) output jobCost output HOURS_PROMPT input numHours return endOfJob() output END_LINE return 9.a. Draw the hierarchy chart and design the logic for a program needed by the managerof the Stengel County softball team, who wants to compute slugging percentages for his players. A slugging percentage is the total bases earned with base hits divided by the player’s number of at-bats. Design a program that prompts the user for a player jersey number, the number of bases earned, and the number of at-bats, and then displays all the data, including the calculated slugging average. The program accepts players continuously until 0 is entered for the jersey number. Use appropriate modules, including one that displays End of jobafter the sentinel is entered for the jersey number.
Programming Logic and Design, 9e Solutions 2-21 Flowchart: main program housekeeping() detailLoop() endOfJob()
Programming Logic and Design, 9e Solutions 2-22 Pseudocode: start Declarations num jerseyNumber num numBasesEarned num numAtBats num sluggingPercent string NUM_PROMPT = “Enter the player’s jersey number: ” string BASES_PROMPT = “Enter the number of bases earned (hits): ” string BATS_PROMPT = “Enter the number of at bats: ” string END_LINE = “End of job” housekeeping() while jerseyNumber <> 0 detailLoop() endwhile endOfJob() stop housekeeping() output NUM_PROMPT input jerseyNumber return detailLoop() output BASES_PROMPT input numBasesEarned output BATS_PROMPT input numAtBats sluggingPercent = numBasesEarned / numAtBats output numBasesEarned output numAtBats output sluggingPercent output NUM_PROMPT input jerseyNumber return endOfJob() output END_LINE return b. Modify the slugging percentage program to also calculate a player’s on-base :
Programming Logic and Design, 9e Solutions 2-23 Flowchart: main program housekeeping() detailLoop() endOfJob()
Programming Logic and Design, 9e Solutions 2-24 Pseudocode: start Declarations num jerseyNumber num numBasesEarned
Programming Logic and Design, 9e Solutions 2-25 num numAtBats num sluggingPercent num numWalks num numSacFlies num onBasePercent string NUM_PROMPT = “Enter the player’s jersey number: ” string BASES_PROMPT = “Enter the number of bases earned (hits): ” string WALKS_PROMPT = “Enter the number of walks: ” string BATS_PROMPT = “Enter the number of at bats: ” string FLIES_PROMPT = “Enter the number of sacrifice flies: ” string END_LINE = “End of job” housekeeping() while jerseyNumber <> 0 detailLoop() endwhile endOfJob() stop housekeeping() output NUM_PROMPT input jerseyNumber return detailLoop() output BASES_PROMPT input numBasesEarned output BATS_PROMPT input numAtBats output WALKS_PROMPT input numWalks output FLIES_PROMPT input numSacFlies sluggingPercent = numBasesEarned / numAtBats onBasePercent = (numBasesEarned + numWalks) / (numAtBats + numWalks + numSacFlies)

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture