Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Plan 4 Process Customer Record

# Example: Process Customer Record

#### File: /Learning Plan 4/example-3-2.html

### Problem Statement

> Write a program that will read (i.e. obtain from user) a customer's name, a purchase amount, and a tax code. The tax code has been validated and will be one of the following:

                0 = tax exempt (0%)
                1 = state sales tax only (5%)
                2 = state and county sales tax (5.5%)
                3 = special sales tax (7%)

> The program must then compute the sales tax and the total amount due, and print (i.e. display on Web page) the customer's name, purchase amount, sales tax, and total amount due.

### The Program Planning Lists

- First the programmer focused on the nouns and verbs to help understand the requirements. Then he/she created variable names and the Process Checklist.

    The List of Input Variables:
        customerName
        purchaseAmount
        taxCode

    The List of Output Variables:
        customerName
        purchaseAmount
        salesTax
        totalAmount

    The Process Checklist:
        Declare all variables
        Obtain customer name, amt, taxcode
        Calculate sales tax
        Calculate total amount
        Display customer details

### The Test Plan

    VARIABLES:

    TEST CASE 1:

        INPUT VALUES: "Fred", "10", "0"

        EXPECTED RESULT: "Fred", 10, 0, 10

    TEST CASE 2:

        INPUT VALUES: "Bill", "100.00", "1"

        EXPECTED RESULT: "Bill", 100.00, 5.00, 105.00

    TEST CASE 3:

        INPUT VALUES: "Sue", "149.99", "2"

        EXPECTED RESULT: "Sue", 149.99, 8.25, 158.24

    TEST CASE 4:

        INPUT VALUES: "Sue", "200", "3"

        EXPECTED RESULT: "Sue", 200, 14.00, 214

### 5. JavaScript Output

- Here's the code:

- Here's the output: