a sales report. Each record in the file contains a customer's number and name, a sales amount and a tax code. The tax code is to be applied to the sales amount to determine the sales tax due for that sale, as follows:

Tax code Sales tax
0 Tax exempt
1 3%
2 5%

The report is to print a heading 'SALES REPORT', and detail lines listing the customer number, name, sales amount, sales tax and the total amount owing.

Task need to do:

Total amount to match the tax using own creativity and logic.

1. Design algorithm [Note: Pseudocode and Flowchart]

2. Write program and use control structures required

• A DOWHILE loop to control the repetition

• A case structure to calculate the sales tax

Assume that the tax code field has been validated and will only contain a value of 0, 1, or 2.

To design an algorithm for creating the sales report, you can follow these steps:

1. Initialize variables for total sales amount and total tax amount.

2. Print the heading 'SALES REPORT'.

3. Read the first record from the file.

4. Enter a DOWHILE loop to iterate through the records until the end of the file is reached.

5. Within the loop, extract the customer's number, name, sales amount, and tax code from the record.

6. Use a case structure to calculate the sales tax based on the tax code:
- If the tax code is 0, set the sales tax to 0.
- If the tax code is 1, calculate the sales tax as 3% of the sales amount.
- If the tax code is 2, calculate the sales tax as 5% of the sales amount.

7. Add the sales tax to the total tax amount.

8. Calculate the total amount owing by adding the sales amount and sales tax.

9. Print the customer number, name, sales amount, sales tax, and total amount owing.

10. Read the next record from the file.

11. Exit the DOWHILE loop when all records have been processed.

12. Finally, print the total sales amount and total tax amount.

Pseudocode:

```
totalSalesAmount = 0
totalTaxAmount = 0

Print "SALES REPORT"

Read customer record from file

DO WHILE not end of file
Extract customer number, name, sales amount, and tax code

SELECT CASE tax code
CASE 0:
salesTax = 0
CASE 1:
salesTax = salesAmount * 0.03
CASE 2:
salesTax = salesAmount * 0.05
END SELECT

totalTaxAmount = totalTaxAmount + salesTax
totalAmountOwing = salesAmount + salesTax

Print customer number, name, sales amount, sales tax, total amount owing

Read next customer record from file

END DO WHILE

Print "Total Sales Amount: ", totalSalesAmount
Print "Total Tax Amount: ", totalTaxAmount
```

Flowchart:

```
START
├─┬─[Print "SALES REPORT"]
│ └─[Read customer record from file]

├─[DO WHILE not end of file]
│ ├─[Extract customer number, name, sales amount, and tax code]
│ │
│ ├─[SELECT CASE tax code]
│ │ ├─[CASE 0]
│ │ │ └─[salesTax = 0]
│ │ ├─[CASE 1]
│ │ │ └─[salesTax = salesAmount * 0.03]
│ │ ├─[CASE 2]
│ │ │ └─[salesTax = salesAmount * 0.05]
│ │ └─[END SELECT]
│ │
│ ├─[totalTaxAmount = totalTaxAmount + salesTax]
│ ├─[totalAmountOwing = salesAmount + salesTax]
│ ├─[Print customer number, name, sales amount, sales tax, total amount owing]
│ └─[Read next customer record from file]

└─┬─[Print "Total Sales Amount: ", totalSalesAmount]
└─[Print "Total Tax Amount: ", totalTaxAmount]
END
```

By using the provided pseudocode and flowchart as a guide, you can now write the program with the necessary control structures to calculate sales tax, display the sales report, and determine the total sales and tax amounts.