95%(43)41 out of 43 people found this document helpful
This preview shows page 20 - 25 out of 26 pages.
Programming Logic and Design, 7eSolutions 2-20c. 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, 7eSolutions 2-21
Programming Logic and Design, 7eSolutions 2-22Pseudocode:startDeclarationsnum jerseyNumbernum numBasesEarnednum numAtBatsnum sluggingPercentnum numWalksnum numSacFliesnum onBasePercentnum gpastring 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 <> 0detailLoop()endwhileendOfJob()stophousekeeping()output NUM_PROMPTinput jerseyNumberreturndetailLoop()output BASES_PROMPTinput numBasesEarnedoutput BATS_PROMPTinput numAtBatsoutput WALKS_PROMPTinput numWalksoutput FLIES_PROMPTinput numSacFliessluggingPercent = numBasesEarned / numAtBatsoutput sluggingPercentonBasePercent = (numBasesEarned + numWalks) / (numAtBats + numWalks + numSacFlies)output onBasePercentgpa = ((onBasePercent * 1.8) + sluggingPercent) / 4output gpaoutput NUM_PROMPTinput jerseyNumberreturnendOfJob()output END_LINEreturn
Programming Logic and Design, 7eSolutions 2-23Find the Bugs10. 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 Zone11. 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, 7eSolutions 2-24Pseudocode:startDeclarationsnum myRandomNumbernum guessstring PROMPT = “Enter a number between 1 and 10: ”string END_LINE = “Thank you for playing”housekeeping()detail()endOfJob()stophousekeeping()myRandomNumber = random(10)output PROMPTinput guessreturndetail()output myRandomNumberreturnendOfJob()output END_LINEreturnUp for Discussion