This is the assignment-Write a C#.NET (call it Lab7) that performs the following:
The program contains an array that holds 10 ZIP codes to which a company delivers. Prompt the user of the program to input a ZIP code and then display a message on screen that indicates whether the ZIP code is one to which the company delivers or not. Finally display all ZIP codes in the array in descending order.

and this is what i have so far but I am lost atm.


public class ZipCodes;
}

public static void Main ()
{
int [] zipCodes = {07017,07050,07018,07019,07003,07200,07306,07304,07302,07495};
int x;
string entryString;
int entryZipCode;
if(textBox1.Text == zipCode[x].ToString)
label2.Text = "We ship to that zip code";
ConsoleWrite.Line( " Sorry we currently do not ship items to this zipCode");
entryString = Console.ReadLine ();
}
}

Can anyone tell me what I am doing wrong? I am really confused about this.

One way of implementing this is to utilize a while loop to walk through your zip code array. The conidtions of the while loop would be while x < array.size and target zip not equal to array[X], then continue to next array element.

First decide whether you are reading from console or from a gui, if from console move readline above, then compare with the string read with entries in your ziparray.

class Program
    {
        static void Main(string[] args)
        {
            string[] zipCodeArray = { "00012", "00013", "00014", "00015", "00016" };
            string searchZipCode = "00015";
            bool found = false;
            int i;
            for (i = 0; i <= zipCodeArray.Count() - 1; i++)
            {
                if (searchZipCode.Trim() == zipCodeArray[i])
                {
                    found = true;

                }
            }

            if (found)
            {
                Console.WriteLine("We can deliver the POST");
            }
            else
            {
                Console.WriteLine("ZIPCODE not found. Cant Deliver the POST");
            }
            Console.ReadLine();
        }
    }

mvkotekar, a few pointers:
One - if someone is clearly doing a homework piece we generally give guidance and pointers rather than complete code as it deprives them of the chance to learn by getting there for themselves if they can copy and paste a solution.
Two - please use [code]

[/code] tags when posting code.
Three - this post is over 2 years dead...i think his homework may be long past due :p

Apologies. What you said was right!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.