ok so im working on a application that displays the charges along with displaying the zip code. I seem to have a IO exception error for the console.clear() line. Is there anything else I need in order to display the charges along with zip code? Im thinking a nested if statement possibly?
Thanks a lot everyone
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PackageDelivery
{
class Program
{
static void Main(string[] args)
{
int zipThatIamLookingFor;
string inValue;
double charges;
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)
{
//this recieves the zip code from the user and stores
//in method
zipThatIamLookingFor = GetZipCode();
//this test the zip code entered by user
Test(zipCode, zipThatIamLookingFor);
//method to display the charges
//displays message
Console.Write("Do you want to enter another zip?");
//takes in user input
inValue = Console.ReadLine();
//takes both upper/lower case letters
if (inValue == "y" || inValue == "Y")
//test the response through if..else loops
moreData = true;
else
moreData = false;
//displays message if bool value = false
Console.WriteLine("Sorry we currently do not deliever to your area.");
} // end of while loop
}
static int GetZipCode()
{
int searchValue;
string inValue;
Console.WriteLine("Test Zipcode: ");
inValue = Console.ReadLine();
searchValue = Convert.ToInt32(inValue);
return searchValue;
} // end of GetZipCode
static double DisplayCharges()
{
//initializing so compilier does not report unassigned local
//variable
double charges = 0;
Console.WriteLine("Price for shipping for your zipcode: ");
return charges;
} // end of displayCharges
static void Test(int[] zipCode, int searchValue)
{
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
//IO exception unhandled
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