Heather Jacobs

Heather Jacobs

  • NA
  • 17
  • 7.3k

using Arrays CheckZip

Aug 2 2018 8:35 PM
part 1
Create a new console application named CheckZip. Write a program for a package delivery service. The program contains an array that holds the ten zip codes to which the company delivers packages. Prompt a user to enter the zip codes, sort the zip codes, and then output the sorted zip codes to the user.
 
part 2
Begin with part I. Edit program by initializing the zip code array to contain a list of 10 zip codes. Add another parallel array that contains ten delivery charges for each of the zip codes. Use a menu system to allow the user to choose from four options: 1.) Print all zip codes 2.) Print all zip codes and delivery charges 3.) Search for a zip code and then display either a message indicating the price of delivery to the zip code or a message indicating that the company does not deliver to the requested zip code. 4.) Exit
Here is what I have for the part 1 but I am a little confused on the 2nd part.
 
using System;
using static System.Console;
namespace CheckZip
{
class CheckZip
{
public static void Main(string[] args)
{
string[] zipCode = { "40475", "40473", "40476", "40481", "40484",
"40481", "40484", "40486", "40488", "40489" };
int x;
string entryZip;
bool ZipFound = false;
Console.WriteLine("Enter a Zip code for delivery");
entryZip = Console.ReadLine();
for (x = 0; x < zipCode.Length && !ZipFound; ++x)
{
if (entryZip == zipCode[0])
{
Console.WriteLine("Delivery to {0} ok", entryZip);
ZipFound = true;
}
if (!ZipFound)
Console.WriteLine("Sorry no deliver to {0}", entryZip);
Console.ReadLine();
}
}
}
}
 
I was a little confused how I do another loop with prices and get the 4 options on there as well.

Answers (2)