Question: A increment counter A B increment counter B increment counter C other : increment error counter ENDCASE In both forms of pseudocode, the processing logic

 A increment counter A B increment counter B increment counter C

A increment counter A B increment counter B increment counter C other : increment error counter ENDCASE In both forms of pseudocode, the processing logic is exactly the same. However, the case solution is much more readable. Let us now look again at Example 4.2. The solution algorithm for this example was earlier expressed as a linear nested IF statement, but it could equally have been expressed as a CASE statement. EXAMPLE 4.4 Process customer record A program is required to read a customer's name, a purchase amount and a tax code. The tax code has been validated and will be one of the following: tax exempt (096) 1 state sales tax only (396) 2 federal and state sales tax (5%) 3 special sales tax (796) The program must then compute the sales tax and the total amount due, and print the customer's name, purchase amount, sales tax and total amount due. A Defining diagram Input cust name purch amt tax code Processing Read customer details Calculate sales tax Calculate total amount Print customer details Output cust name purch amt sales tax total amt B Solution algorithm The solution algorithm will be expressed using a CASE statement. Process_customer _record Read cust name, purch amt, tax code CASE OF tax code 2 0 : sales, tax 1 : sales-tax = purch-amt . 0.03 2 : sales, tax = purch-arnt , O.05 3 : sales tax purch amt 0.07 3 4 ENDCASE total-amt-purch-amt + sales-tax Print cust name, purch amt, sales, tax, total amt END

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!