Hey guys.. I am having a small problem with a program I wrote, the problem is that I have an array that stores a user input and it should be numeric only when the user inputs an invalid input like let's say J the program will notifiy them that they have entered an invalid input that is done through a try catch block and that closes the program after that and never ask them again.. Which I want it to ask them again.. Is there anyway I can loop back after the catch work?
Here is the code I wrote
double[] arraySize = new double[testInput]; // an intitlized array inside the statement to for simplicty.. It is used to access the memory address and stores the user input.
if (testInput >= MIN && testInput < MAX) // Limiting the input for each test
{
for (int counter = 0; counter < arraySize.Length; counter++) // counting on the index length which is the array size
{
Console.WriteLine("Enter number " + counter + ":"); // allowing the user to input for the test
input = double.Parse(Console.ReadLine()); // storing the user input
if (input >= MIN_TEST && input <= MAX_TEST)
{
arraySize[counter] = input;
}
else
{
Console.WriteLine("\nInvalid Input..");
counter--;
continue;
}
temp += arraySize[counter]; // adding the info to the array size
}
Of course there is more of the code but this is where I am stuck right now and I don't think the other lines affect it.
Thank you