Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions