Beginner array program, need help!!!
-
Here is what I have so far: using System; namespace ZipArray { class Program { public class ZipSort { string[] zipCodes = new string[10] { "33701", "33702", "33703", "33704", "33705", "33706", "33707", "33708", "33709", "33710"}; int x; Console.Write("Please enter a zip-code : "); string zipSearch = Console.ReadLine(); bool found = false; foreach(string zip in zipCodes) { if (zip == zipSearch) { found = true; break; } } Console.WriteLine(); if (found) { Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch); } else { Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch); Console.WriteLine(); Console.WriteLine("The full list is :"); Console.WriteLine(); Array.Reverse(zipCodes); for(x=0; x Console.WriteLine(zipCodes[x]); } } I have been unable to make this program run correctly thus far, I am trying to make it to where it will allow the user to enter a zip code and if it is on the list it will read "the zip code "0" is delivered to" and after that to sort the zip codes in descending order. Any help would be much appreciated!
-
Here is what I have so far: using System; namespace ZipArray { class Program { public class ZipSort { string[] zipCodes = new string[10] { "33701", "33702", "33703", "33704", "33705", "33706", "33707", "33708", "33709", "33710"}; int x; Console.Write("Please enter a zip-code : "); string zipSearch = Console.ReadLine(); bool found = false; foreach(string zip in zipCodes) { if (zip == zipSearch) { found = true; break; } } Console.WriteLine(); if (found) { Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch); } else { Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch); Console.WriteLine(); Console.WriteLine("The full list is :"); Console.WriteLine(); Array.Reverse(zipCodes); for(x=0; x Console.WriteLine(zipCodes[x]); } } I have been unable to make this program run correctly thus far, I am trying to make it to where it will allow the user to enter a zip code and if it is on the list it will read "the zip code "0" is delivered to" and after that to sort the zip codes in descending order. Any help would be much appreciated!
-
Here is what I have so far: using System; namespace ZipArray { class Program { public class ZipSort { string[] zipCodes = new string[10] { "33701", "33702", "33703", "33704", "33705", "33706", "33707", "33708", "33709", "33710"}; int x; Console.Write("Please enter a zip-code : "); string zipSearch = Console.ReadLine(); bool found = false; foreach(string zip in zipCodes) { if (zip == zipSearch) { found = true; break; } } Console.WriteLine(); if (found) { Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch); } else { Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch); Console.WriteLine(); Console.WriteLine("The full list is :"); Console.WriteLine(); Array.Reverse(zipCodes); for(x=0; x Console.WriteLine(zipCodes[x]); } } I have been unable to make this program run correctly thus far, I am trying to make it to where it will allow the user to enter a zip code and if it is on the list it will read "the zip code "0" is delivered to" and after that to sort the zip codes in descending order. Any help would be much appreciated!
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] zipCodes = new string[10]{"33701","33702","33703","33704","33705", "33706","33707","33708","33709","33710"}; Console.Write("Please enter a zip-code : "); string zipSearch = Console.ReadLine(); bool found = false; foreach (string zip in zipCodes) { if (zip == zipSearch) { found = true; break; } } Console.WriteLine(); if (found) { Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch); } else { Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch); Console.WriteLine(); Console.WriteLine("The full list is :"); Console.WriteLine(); } Array.Reverse(zipCodes); for (int i = 0; i < zipCodes.Length; i++) { Console.WriteLine(zipCodes[i]); } Console.WriteLine("Press a key to Continue."); Console.ReadLine(); } } }
-
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string[] zipCodes = new string[10]{"33701","33702","33703","33704","33705", "33706","33707","33708","33709","33710"}; Console.Write("Please enter a zip-code : "); string zipSearch = Console.ReadLine(); bool found = false; foreach (string zip in zipCodes) { if (zip == zipSearch) { found = true; break; } } Console.WriteLine(); if (found) { Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch); } else { Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch); Console.WriteLine(); Console.WriteLine("The full list is :"); Console.WriteLine(); } Array.Reverse(zipCodes); for (int i = 0; i < zipCodes.Length; i++) { Console.WriteLine(zipCodes[i]); } Console.WriteLine("Press a key to Continue."); Console.ReadLine(); } } }