Pseudocode start declarations num jerseynumber num

• Homework Help
• 20
• 97% (31) 30 out of 31 people found this document helpful

This preview shows page 15 - 19 out of 20 pages.

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 Find the Bugs 10. Your student disk contains files named 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 enter a guess and the program can determine whether the user was correct.)
Programming Logic and Design, 6e Solutions 2-17 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
Programming Logic and Design, 6e Solutions 2-18 12. Many programming style guides are published on the Web. These guides suggest good identifiers, explain standard indentation rules, and identify style issues in specific programming languages. Find style guides for at least two languages (for example, C++, Java, Visual Basic, or C#) and list any differences you notice.