Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will write a function named findZips. It will receive one parameter, a Zip code in the range of 0 through 99999. It will return

You will write a function named findZips. It will receive one parameter, a Zip code in the range of 0 through 99999. It will return one parameter, the state code associated with that Zip code. If the parameter is out of the range, or is not found within the table described below, your function should return zero in register 0.

This function is intended to validate a United States Postal Service ZIP code, and to return the state associated with that ZIP code. Your function will include an array of DCD statements, starting label Zips, which comprises 61 triplets of integer numbers:

  • The state code
  • The lowest ZIP code in that state's range
  • The highest ZIP code in that state's range

(The state code is based upon the old Federal Information Processing Standards (FIPS), which are now part of an ANSI standard.) This triplet corresponds to the following C++ struct:

struct { int stateCode; int lowZip; int highZip; } zipRec;

For example, the values for the state of California are:

Z6 DCD 6 , 90000 , 96199 ; CA

The label Z6 is provided because the VisUAL emulator requires one for DCD statements. The state code is 6, the low ZIP code is 90000, and the high ZIP code for California is 96199.

Note that some states have more than one ZIP code range associated with them. These labels will have letters appended to the name. The labels have no particular significance for the solution of this problem.

Your function will receive an integer input value containing a ZIP code (the search ZIP code) in register 0. Your program should do the following:

  • Determine if the ZIP code parameter is within limits (ZIP > 0 and ZIP < 99999) and return 0 immediately if the parameter is out of range.
  • Search the table from beginning to end looking for the state which contains this ZIP code:
    • The low ZIP code in the table entry is less than or equal to the search ZIP code.
    • The high ZIP code in the table entry is greater than or equal to the search ZIP code.
  • When a matching table entry is found, set the following result variable:
    • Register zero shall be set to the state code from the matching table entry if found
  • If no matching table entry is found, set register 0 to zero.
  • The function ends at this point.

For grading, the instructor will call your function with various valid, invalid, and missing ZIP codes as parameters. Your test data should include:

  • a negative number,
  • zero,
  • a ZIP code which is within limits but not found in any table entry (such as 333),
  • a valid ZIP code (such as 91371, the Pierce College ZIP code), and
  • a number greater than 99999

You do not turn in the test data.

The input will be the following variable in your program:

ThisSt DCD some integer value

The actual number of array entries will be in a variable named maxI. You may use this as a limit in a for loop.

The output of your program will be the values placed in the following variables:

  • GoodZip : a value of 1 if the ZIP code in ThisZip is valid and found in the table, or 0 if not
  • ThisSt: the state code from the matching entry in the table, or zero if the ZIP code did not match any entry

Your program must use the variable names ThisZip, GoodZip, and ThisSt.

Your program will be tested with the set of values shown later in this assignment. Copy and paste the Zips table into your program. You may assume that the Zips array will contain the number of entries in the maxI value.

You should copy and paste this table into your function.

maxI EQU 61 Zips DCD 2,99500,99999 ; AK (Z2) Z1 DCD 1,35000,36999 ; AL Z5 DCD 5,71600,72999 ; AR Z4 DCD 4,85000,86999 ;, AZ Z6 DCD 6,90000,96199 ; CA Z8 DCD 8,80000,81999 ; CO Z9 DCD 9,6000,6389 ; CT Z9B DCD 9,6391,6999 ; CT Z11A DCD 11,20000,20099 ; DC Z11B DCD 11,20200,20599 ; DC Z11C DCD 11,56900,5699 ; DC Z10 DCD 10,19700,19999 ; DE Z12 DCD 12,32000,34999 ; FL Z13A DCD 13,30000,31999 ; GA Z13B DCD 13,39901,39901 ; GA Z15 DCD 15,96700 ,96899 ; HI Z19 DCD 19,50000,52999 ; IA Z16 DCD 16,83200 ,83999 ; ID Z17 DCD 7,60000,62999 ; IL Z18 DCD 18,46000,47999 ; IN Z20 DCD 20,66000,67999 ; KS Z21 DCD 21,40000,42799 ; KY Z22 DCD 22,70000,71599 ; LA Z25 DCD 25,1000,2799 ; MA Z24 DCD 24,20600,21999 ; MD Z23 DCD 23,3900,4999 ; ME Z26 DCD 26,48000,49999 ; MI Z27 DCD 27,55000,56999 ; MN Z29 DCD 29,63000,65999 ; MO Z28 DCD 28,38600,9900 ; MS Z28 DCD 28,39902,39999 ; MS Z3 DCD 3,59000,59999 ; MT Z37 DCD 37,27000,28999 ; NC Z38 DCD 38,58000,58999 ; ND Z31 DCD 31,68000,69999 ; NE Z33 DCD 33,3000,3899 ; NH Z34 DCD 34,7000,8999 ; NJ Z35 DCD 35,87000,88999 ; NM Z32 DCD 32,89000,89999 ; NV Z36A DCD 36,501,501 ; NY Z36B DCD 36,544,544 ; NY Z36C DCD 36,6390,6390 ; NY Z36D DCD 36,10000,14999 ; NY Z39 DCD 39,43000,45999 ; OH Z40 DCD 40,73000,74999 ; OK Z41 DCD 41,97000,97999 ; OR Z42 DCD 42,15000,19699 ; PA Z44 DCD 44,2800,2999 ; RI Z45 DCD 45,29000,29999 ; SC Z46 DCD 46,57000,57999 ; SD Z47 DCD 47,37000,38599 ; TN Z48A DCD 48,75000,79999 ; TX Z48B DCD 48,88500,88599 ; TX Z49 DCD 49,84000,84999 ; UT Z51 DCD 51,20100,20199 ; VA Z51 DCD 51,22000,24699 ; VA Z50 DCD 50,5000,5999 ; VT Z53 DCD 53,98000,99499 ; WA Z55 DCD 55,53000,54999 ; WI Z54 DCD 54,24700,26999 ; WV Z56 DCD 56,82000,83199 ; WY ; End of Zips table

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

LO1 Explain how the workforce is changing in unpredicted ways.

Answered: 1 week ago