Programming Logic and Design 7e Solutions 2 20 c Modify the softball program to

Programming logic and design 7e solutions 2 20 c

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

Programming Logic and Design, 7e Solutions 2-20 c. Modify the softball program to also compute a gross production average (GPA) for each player. A GPA is calculated by multiplying a player’s on-base percentage by 1.8, :
Programming Logic and Design, 7e Solutions 2-21
Programming Logic and Design, 7e Solutions 2-22 Pseudocode: start Declarations num jerseyNumber num numBasesEarned num numAtBats num sluggingPercent num numWalks num numSacFlies num onBasePercent num gpa 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 output sluggingPercent onBasePercent = (numBasesEarned + numWalks) / (numAtBats + numWalks + numSacFlies) output onBasePercent gpa = ((onBasePercent * 1.8) + sluggingPercent) / 4 output gpa output NUM_PROMPT input jerseyNumber return endOfJob() output END_LINE return
Programming Logic and Design, 7e Solutions 2-23 Find the Bugs 10. Your downloadable files for Chapter 2 include DEBUG02-01.txt, DEBUG02-02.txt, and DEBUG02-03.txt. Each file starts with some comments that describe the problem. Comments are lines that begin with two slashes (//). Following the comments, each file contains pseudocode that has one or more bugs you must find and correct. Answer : Please see the DEBUG02-01.txt, DEBUG02-02.txt, and DEBUG02-03.txt solution files. Game Zone 11. Create a flowchart or pseudocode that shows the logic for a program that generates a random number, then asks the user to think of a number between 1 and 10. Then display the randomly generated number so the user can see whether his or her guess was accurate. (In future chapters you will improve this game so that the user can entera guess and the program can determine whether the user was correct.)
Programming Logic and Design, 7e Solutions 2-24 Pseudocode: start Declarations num myRandomNumber num guess string PROMPT = “Enter a number between 1 and 10: ” string END_LINE = “Thank you for playing” housekeeping() detail() endOfJob() stop housekeeping() myRandomNumber = random(10) output PROMPT input guess return detail() output myRandomNumber return endOfJob() output END_LINE return Up for Discussion

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture