2
Answers

Array problem

Prime b

Prime b

12y
2.7k
1
This is my problem

Write a program for a package delivery service. Th e program
contains an array that holds the ten zip codes to which the
company delivers packages. Prompt a user to enter a zip
code and display a message indicating whether the zip code
is one to which the company delivers


My question is if you run it, then its going to display 9 messages "Sorry we dont deliver package to this location", and 1 message "We deliver shipping to this location". I know its something about my loop but i am not sure what it is

What I have done


            int[] zipCode = new int[10] { 28303, 21303, 9103, 6532, 9011, 6534, 8426, 0989, 4735, 8643 };
            string inputString;
            int validZipCode;
            Console.WriteLine("Please enter zipcode");
            inputString = Console.ReadLine();
            validZipCode = Convert.ToInt32(inputString);
            for (int x = 0; x < zipCode.Length; ++x)
            {
                if (validZipCode == zipCode[x])
                {
                    Console.WriteLine("We deliver shipping to this location");

                }
                else
                    Console.WriteLine(" Sorry we dont deliver package to this location");
Answers (2)