Unformatted text preview: carpet (dollars per square foot). Calculate the total cost of the carpet and print a message stating whether whether we can afford to purchase the carpet if our total budget is $500. Part 2: Algorithm Verifcation The following algorithm multiplies two values (a and b) by adding a to itself b times: Get values for a and b If (either a = 0 or b = 0) then Set the value of product to 0 Else Set the value of count to 0 Set the value of product to 0 W h i l e ( count < b ) do Set the value of product to ( product + a ) Set the value of count to ( count + 1 ) End of loop Print the value of product Stop 1. Describe exactly what this algorithm will produce as output for each of the following two cases. State whether that output is correct or incorrect. Case 1: a = 2, b = 4 Case 2: a = 2, b = 4 2. If the algorithm produces the incorrect result for either of the two cases above, explain why it does not work correctly....
View
Full Document
 Fall '08
 SHAUNAKPAWAGI
 Input/output, single input value

Click to edit the document details