# Programming logic and design 9e solutions 9

• 38
• 100% (7) 7 out of 7 people found this document helpful

This preview shows page 11 - 19 out of 38 pages.

Programming Logic and Design, 9eSolutions 9-Pseudocode:startDeclarationsnum numbernum sumnum productnum QUIT = 0output “Enter a number or ”, QUIT, “ to quit”input numberwhile <> QUITdisplayNumbers(number)sum = calcSum(number)product = calcProduct(number)output “The sum is ”, sum, “ and the product is ”, productoutput “Enter a number or ”, QUIT, “ to quit”input number12
Programming Logic and Design, 9e6.Create the logic for a program that calls a method that computes and returns a homeowner’s profit from the home’s sale. Arguments passed to the method include
Programming Logic and Design, 9eSolutions 9-Pseudocode:startDeclarationsnum salePricenum mortPayoffnum commissionnum feesnum taxesnum profitinput salePrice, mortPayoff, commission, fees, taxesprofit = calculateProfit(salePrice, mortPayoff, commission, fees, taxes)output profitstopnum calculateProfit(num price, num payoff, num comm, num fees, num taxes)Declarationsnum profitprofit = price - (payoff + comm + fees + taxes)return profit14
Programming Logic and Design, 9eSolutions 9-7.Create the logic for a program that continuously prompts the user for three numeric values that represent the length, width, and depth in inches of a proposed patio. Include two overloaded methods that compute the cost of construction. One method accepts all three parameters and calculates the cost at \$0.12 per cubic inch. The other takes two numeric parameters that represent length and width and uses a default depthof 4 inches. Accept input and respond as follows:When the user enters zero for the length value, end the program.If the user enters a negative number for any value, continue to reprompt the user until the value is not negative.If all numbers entered are greater than 0, call the method version that accepts three.If the depth value is zero, call the version of the method that uses the default depth.
15
Programming Logic and Design, 9eSolutions 9-16
Programming Logic and Design, 9eSolutions 9-17
Programming Logic and Design, 9eSolutions 9-Pseudocode:startDeclarationsnum lengthnum widthnum depthoutput “Enter a value for the length, or zero to quit”input lengthwhile length < 0output “Please reenter a value for the length”input lengthendwhileif length > 0 thenoutput “Enter a value for the width”input widthwhile width < 0output “Please reenter the value for the width”input widthendwhileoutput “Enter a value for the depth”input depthwhile depth < 0