Page 1 of 1

Highschool cs class c++ beginner needing help please

Posted: Fri Apr 29, 2022 6:51 am
by answerhappygod
Highschool cs class c++ beginner needing help
please
Highschool Cs Class C Beginner Needing Help Please 1
Highschool Cs Class C Beginner Needing Help Please 1 (98.87 KiB) Viewed 34 times
Write code that asks the user for a zip code. Given the zip code, tell the user what the state abbreviation and the state name are for the state in which the zip is located. A sample dialog might be: enter zip 80001 state abbreviation Co state name Colorado enter zip 86550 state abbreviation AZ state name Arizona Arizona enter zip 99999 invalid zip code enter zip stop thank you and have a nice day! You are given two text files that contain the data needed for you to produce the results. The first file contains a list of state names and abbreviations: state name 14 characters one space state abbr 2 characters The second file contains ranges of zip codes, and the abbreviation of the state for that range: state abbr 2 characters 5 characters one space lower range one space upper range 5 characters The state name/abbreviation file has 50 records, one per state. The file is sorted alphabetically by state abbreviation. The zip code file has some number of records, which varies from time to time as the Post Office adjusts the zip code coverage to align with the US's changing population. You don't know how many records it has. There is also some overlap in zip code coverage, which in some cases requires the file to contain multiple records per state, and also requires a particular ordering of the zip code ranges. These details will be discussed in class. Processing:
The key to this part of the assignment is to populate and use two different sets of parallel arrays. One set contains state names and abbreviations, and the other set contains numeric zip code information and state abbreviations. Read the state name/abbreviation file and create two arrays, one for state names and one for state abbreviations. Use getline. These two arrays are parallel arrays...the nth state name corresponds with the nth state abbreviation. Read the zip code file and create three arrays: one for the zip code lower bounds, one for the upper bounds, and one for the associated state abbreviations. These three arrays are parallel arrays. You now have a total of five arrays. But note that this is very distinctly two sets of parallel arrays, one with two, and one with three, and that there is no direct linkage between the two, other than the fact that both sets contain a state abbreviation array. The abbreviations arrays are not equivalent; one contains exactly 50 abbreviations, arranged alphabetically, and the other contains some other number of abbreviations, in some other order. Loop reading zip codes from the console. The user indicates there are no more zip codes by entering "stop." Given a zip code, find it in the zip codes arrays. You do this by searching the lower and upper bounds arrays, finding the place where the zip code falls. Use that index to get the state abbreviation for that state. Make sure you use the correct state abbreviation array. Next, search the state names/abbreviations arrays for the abbreviation, and use that index to get the state name. Display the state abbreviation and name.