Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First youll create a list of zip codes, stored as values of array elements, as follows: Ask for the quantity of 5-digit zip codes youll

First youll create a list of zip codes, stored as values of array elements, as follows:

Ask for the quantity of 5-digit zip codes youll need. Allow the user to enter 0 as well. Save to a variable.

i.Use try-catch to make sure that an integer is entered. Loop back and make the user try again until an integer is entered.

Ask for that many 5-digit zip codes (perhaps youll use a For loop). Make sure that the user types in 5 digits. Make them try again and again until they give a 5-digit value.

i.Of course, if the user entered 0 in step a, your program wont ask for any 5-digit zip codes.

Save each zip code as an array element. I would probably make the arrays data type be string (giving you a length property to work with when youre checking to make sure its 5 digits).

Now, as long as your quantity wasnt 0, you have the array that holds a varying quantity of zip codes of areas to which this company makes deliveries.

If the quantity is not 0, prompt the user to enter a 5-digit zip code. Make them enter 5 digits and repeat if they dont get it right. Save the 5-digit zip code to a variable.

If the quantity was not 0, have your code check to see if the zip code entered in at step #3 exists in the array of available zip codes (created in step #1).

If the zip code entered in at step #3 exists in the array, set a boolean variable named zipExists (or something like that) equal to true.

If the zip code entered does not exist in the array, set the boolean variable equal to false.

If the quantity was not 0, and If the boolean variable set in step #4 is true, display a message to the screen indicating that the zip code exists. Make sure that the message includes the zip code that was keyed in at step #4.

If the boolean variable = false, display a message, including the zip code in the message, saying that the zip code doesnt exist in the list.

If, on the other hand, steps 3-5 never happened because the quantity was 0, write a message stating that there are not zip codes to validate against.

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago