Hi there, I'm doing this assignment for school, and I have this allmost figured out, but I am getting 2 error messages: Here's the code, and what is is supposed to do is commented at the beginning:
Code:
//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.
using System;
public class ZipArray
{
public static void Main()
{
int[] validZip = { 00001, 00002, 00003, 00004, 00005, 00006, 00007, 00008, 00009, 00010 };
int x;
string zipString;
int entryId;
Console.Write("Enter a Zip Code");
zipString = Console.ReadLine();
x = Array.BinarySearch(validZip, entryId);
if (x = validZip)
Console.WriteLine("Yes, we ship to zip code {0}", entryId);
else
Console.WriteLine("We do not ship to Zip code {0}", entryId);
}
}
public class SortArray
{
public static void Sort()
{
int[] validZip = { 00001, 00002, 00003, 00004, 00005, 00006, 00007, 00008, 00009, 00010 };
int x;
Array.Sort(validZip);
for(x=0; x<validZip.Length; ++x)
Console.WriteLine(validZip[x]);
}
}
the error I am getting in having the program indicate whether or not the zip code is valid is on line 21
it says "cannot implicitly convert type 'int[]' to 'int'
and on the same line it says "cannot implicitly convert type 'int' to 'bool'
did I miss a for statement somewhere?
the second error is when I go to sort the zip codes in ascending order, it says
"The name 'Array' does not exist in the current context"
and
"the name 'Console' does not exist in the current context."
what does that mean?