ok tweaked it a bit more:
I now need to adjust something at line 57 where the console will grab the dictionary method value..If i put "null" (totally wrong to do) it displays line 59 nevertheless..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PackageDelivery
{
class PackageDeliveryCharge
{
static void Main()
{
int zipThatIamLookingFor;
string inValue;
double showCharge;
string usr;
bool moreData = true;
int[] zipCode = new int[10]
{ 32309, 32398, 32345, 32211,
32215, 32312, 32317, 32308, 32356, 32349 };
double[] deliveryCharges = new double[10] { 10.00, 12.00, 20.00, 1.00, 5.00,
7.00, 2.00, 50.00, 80.00, 75.00 };
while (moreData == true)
{
zipThatIamLookingFor = GetZipCode();
showCharge = DisplayCharges();
Test(zipCode, zipThatIamLookingFor, showCharge);
Console.Write("Do you want to enter another zip?");
inValue = Console.ReadLine();
if (inValue == "y" || inValue == "Y")
moreData = true;
else
moreData = false;
} // end of while loop
}// end of main
static int GetZipCode()
{
int searchValue;
string inValue;
Console.WriteLine("Please enter ZipCode: ");
inValue = Console.ReadLine();
searchValue = Convert.ToInt32(inValue);
return searchValue;
} // end of GetZipCode
static double DisplayCharges()
{
//string 'usr' declares usr variable in inner scope 'if" and allows child scope to access parent scope data without
//overlap
string usr = ;
double charges = 0;
Console.WriteLine("You charges for requested zip code: ");
var ZipCharges = new Dictionary<string, double>
{
{"32309", 10.00},
{"32398", 12.00},
{"32345", 20.00},
{"32211", 1.00},
{"32215", 5.00},
{"32312", 7.00},
{"32317", 2.00},
{"32308", 50.00},
{"32356", 80.00},
{"32349", 75.00}
}; // end of Dictionary lookoup
//this later scope includes block of code in the previous "outer" scope . So inner block containing "earlier" variable
//cant refer to later variable in a place earlier than its declaration.
if (ZipCharges.ContainsKey(usr))
{
//declares 'input' identifiers for variables on the writeline statement
string input= "";
Console.WriteLine("It will cost ${0} to deliver to {1}", ZipCharges[input], input);
}
return charges;
} // end of DisplayCharges
static void Test(int[] zipCode, int searchValue, double showCharge)
{
bool isItThere = false;
for (int i = 0; i < zipCode.Length; i++)
{
if (zipCode[i] == searchValue)
{
isItThere = true;
i = zipCode.Length;
} // end of if loop
} // end of for loop
Console.Clear();
if (isItThere == true)
Console.WriteLine("Zip is in the delivery area!");
else
Console.WriteLine("Zip is not in the delivery area!");
} // end of Test method
} // end of class
} // end of namespace