05 Jun Programming Logic and Design, 6th Edition
Question
Programming Logic and Design, 6th Edition
Chapter 2
Exercises
1. Explain why each of the following names does or does not seem like a good variable name to you.
2. IfmyAge andyourRate are numeric variables, anddepartmentName is a string variable, which of the following statements are valid assignments? If a statement is not valid, explain why not.
3. Assume thatcost = 10 andprice = 12. What is the value of each of the following expressions?
4. Draw a typical hierarchy chart for a paycheck-producing program. Try to think of at least 10 separate modules that might be included. For example, one module might calculate an employee’s dental insurance premium.
5 . Draw the hierarchy chart and then plan the logic for a program for the sales manager of The Couch Potato Furniture Company. The manager needs a program to determine the profit on any item sold. Input includes the wholesale price and retail price for an item. The output is the item’s profit, which is the retail price minus the wholesale price. Use three modules. The main program declares global variables and calls housekeeping, detail, and end-of-job modules. The housekeeping module prompts for and accepts a wholesale price. The detail module prompts for and accepts the retail price, computes the profit, and displays the result. The end-of-job module displays the message “Thanks for using this program”.
6. a.Draw the hierarchy chart and then plan the logic for a program that calculates the gown size a student needs for a graduation ceremony. The program uses three modules. The first prompts a user for and accepts the student’s height in inches. The second module accepts the student’s weight in pounds and converts the student’s height to centimeters and weight to grams. Then, it calculates the graduation gown size needed by adding 1/3 of the weight in grams to the value of the height in centimeters. The program’s output is the gown size the student should order. There are 2.54 centimeters in an inch and 453.59 grams in a pound. Use named constants wherever you think they are appropriate. The last module displays the message “End of job”.
b. Revise the size-determining program to execute continuously until the user enters 0 for the height in inches.
7. Draw the hierarchy chart and design the logic for a program that contains housekeeping, detail loop, and end-of-job modules, and that calculates the service charge customers owe for writing a bad check. The main program declares any needed global variables and constants and calls the other modules. The housekeeping module displays a prompt for and accepts a customer’s last name. While the user does not enter “ZZZZ” for the name, the detail loop accepts the amount of the check in dollars and cents. The service charge is computed as $20 plus 2 percent of the check amount. The detail loop also displays the service charge and then prompts the user for the next customer’s name. The end-of-job module, which executes after the user enters the sentinel value for the name, displays a message that indicates the program is complete.
8. Draw the hierarchy chart and design the logic for a program for the owner of Bits and Pieces Manufacturing Company, who needs to calculate an employee’s projected salary following a raise. The input is the name of the employee, the employee’s current weekly salary, and the percentage increase expressed as a decimal (for example, 0.04 for a 4 percent raise). Design the program so that it runs continuously for any number of employees using three modules. The housekeeping module prompts the user for the percent raise that will be applied to every employee, and prompts for the first employee’s name. The detail loop executes continuously until the user enters “XXX” for the employee’s name. The detail loop gets the employee’s weekly salary, applies the raise, produces the result, and prompts for the next employee name. The end-of-job module, which executes after the user enters the sentinel value for the name, displays a message that indicates the program is complete.
9. Draw the hierarchy chart and design the logic for a program for the manager of the Jeter County softball team, who wants to compute batting averages for his players. A batting average is computed as hits divided by at-bats, and is usually expressed to three decimal positions (for example, .235). Design a program that prompts the user for a player jersey number, the number of hits, and the number of at-bats, and then displays all the data, including the calculated batting average. The program accepts players continuously until 0 is entered for the jersey number. Use appropriate modules, including one that displays “End of job” after the sentinel is entered for the jersey number.
10. 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.)
11. 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.
12. In this chapter, you learned the term mnemonic, which is a memory device like the sentence “Every good boy does fine.” Another popular mnemonic is “May I have a large container of coffee?” What is its meaning? Have you learned other mnemonics as you have studied various subjects? Describe at least five other mnemonics that people use for remembering lists of items.
13. What advantages are there to requiring variables to have a data type?
14. Would you prefer to write a large program by yourself, or work on a team in which each programmer produces one or more modules? Why?
15. Extreme programming is a system for rapidly developing software. One of its tenets is that all production code is written by two programmers sitting at one machine. Is this a good idea? Does working this way as a programmer appeal to you? Why or why not?
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
