# Draw the hierarchy chart and design the logic for a

• Homework Help
• 41
• 94% (172) 161 out of 172 people found this document helpful

This preview shows page 18 - 23 out of 41 pages.

##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter 1 / Exercise 2
JavaScript: The Web Warrior Series
Vodnik
Expert Verified
8.Draw the hierarchy chart and design the logic for a program that calculates the projected cost of an automobile trip. Assume that the user’s car travels 20 miles per gallon of gas. Design a program that prompts the user for a number of miles driven and a current cost per gallon. The program computes and displays the cost of the trip as well as the cost if gas prices rise by 10 percent. The program accepts data continuously until 0 is entered for the number of miles. Use appropriate modules, including one that displays End of programwhen the program is finished.
##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter 1 / Exercise 2
JavaScript: The Web Warrior Series
Vodnik
Expert Verified
Programming Logic and Design, 8eSolutions 2-19Flowchart: Pseudocode:startDeclarationsstring numMilesDrivennum costPerGallonnum tripCostnum newTripCostmain programhousekeeping()detailLoop()endOfJob()
Programming Logic and Design, 8e
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, 8eSolutions 2-21Flowchart: Pseudocode:startDeclarationsnum jerseyNumbernum numBasesEarnednum numAtBatsmain programhousekeeping()detailLoop()endOfJob()
Programming Logic and Design, 8eSolutions 2-22num sluggingPercentstring 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 <> 0detailLoop()endwhileendOfJob()stophousekeeping()output NUM_PROMPTinput jerseyNumberreturndetailLoop()output BASES_PROMPTinput numBasesEarnedoutput BATS_PROMPTinput numAtBatssluggingPercent = numBasesEarned / numAtBatsoutput sluggingPercentoutput NUM_PROMPTinput jerseyNumberreturnendOfJob()output END_LINEreturn