Okay I have created a validation loop which addresses the user entering a number between 10 and 50, as long as it is within these parameters it is supposed to ask for another number. When it is out of these parameters the program should let the user know it is outside the parameter and end the process. Below is what I have written, not sure where I went wrong as it always says it is a valid number, as long as the first number is valid.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Validator
{
class Validator
{
public static void Main(string[] args)
{
//initialize variables
String userInput = "";
int userInfo = 0, intValue;
//provide instructions to the user
Console.WriteLine("Please enter a value between 10 and 50:");
//start the read process
userInput = Console.ReadLine();
//parse the user input
int numValue;
bool parsed = Int32.TryParse(userInput, out numValue);
//while loop parameters
while ((numValue >= 10) && (numValue <= 50))
{
intValue = Convert.ToInt32(userInfo);
userInfo += intValue;
Console.WriteLine("Your Number is within the parameters, enter another number.");
userInput = Console.ReadLine();
}
//end of program lines printed once number is outside the range
Console.WriteLine("The Number you have entered is outside the parameters");
Console.Read();
}
}
}
Any assistance is appreciated, thanks.