This is very basic and you already have the algorithm. How complex and/or robust you want to make it is up to you.
Personally I'd use a struct/class like this:
public struct MeasurementBoundsF
{
public static readonly MeasurementBoundsF Empty = new MeasurementBoundsF();
private float highLimit;
private float lowLimit;
public MeasurementBoundsF(float lowLimit, float highLimit)
{
if (highLimit > lowLimit)
{
this.lowLimit = lowLimit;
this.highLimit = highLimit;
}
else
{
this.lowLimit = highLimit;
this.highLimit = lowLimit;
}
}
public float HighLimit
{
get { return highLimit; }
}
public float LowLimit
{
get { return lowLimit; }
}
public PassFail GetPassFail(float measuredValue)
{
return (measuredValue <= highLimit) && (measuredValue >= lowLimit) ? PassFail.Pass : PassFail.Fail;
}
}
I've used an enum instead of a bool so I can extend the possible results in future:
public enum PassFail
{
Fail = 0,
Pass = 1
}
In use you could do something like this:
float measuredValue;
float highLimit;
float lowLimit;
Console.Write("Measured value? ");
if (float.TryParse(Console.ReadLine(), out measuredValue))
{
Console.Write("High limit? ");
if (float.TryParse(Console.ReadLine(), out highLimit))
{
Console.Write("Low limit? ");
if (float.TryParse(Console.ReadLine(), out lowLimit))
{
MeasurementBoundsF measurementBoundsF = new MeasurementBoundsF(lowLimit, highLimit);
Console.WriteLine(measurementBoundsF.GetPassFail(measuredValue));
}
else
Console.WriteLine("Low limit was invalid");
}
else
Console.WriteLine("High limit was invalid");
}
else
Console.WriteLine("Measured value was invalid");
Console.ReadKey();
If you don't understand it then I suggest you purchase a book or two and study and/or study some online beginners tutorials.
If this is for homework (which I suspect), I would strongly suggest you don't copy and paste the above as your tutor may ask you to explain it, and could quite possibly visit this site (many do) and will know you have cheated.