What i'm trying to do is to stop the program from going passed the number already guessed.. i can get it to stop so that it doesen't guess above 100 or below 0..
but say u go higher from 50 to 75, if i press lower my math will go below 50, which it shouldn't... this is what i got
Sub Main()
Dim num As Integer
Dim counter As Integer
Console.WriteLine("Think of a number in the range [1 .. 100] and I will guess what it is.")
Console.WriteLine("Please direct my guess with a lower or upper case response of H, L, or C")
counter = 1
Console.WriteLine("50 [H, L, C]:")
Do While Console.ReadLine <> "y"
If Console.ReadLine.ToLower = "h" Then
num = CInt(((101 - num) / 2) + num)
Console.WriteLine(CStr(num) & (" [H, L, C]: "))
ElseIf Console.ReadLine.ToLower = "l" Then
num = CInt(num / 2)
Console.WriteLine(CStr(num) + (" [H, L, C]: "))
ElseIf Console.ReadLine.ToLower = "c" Then
Console.WriteLine("Correct")
Console.WriteLine("")
Console.WriteLine("I guessed your number in " & CStr(counter) & " tries")
Console.WriteLine("Exit Y/N")
Console.ReadLine()
End If
counter += 1
loop
End ub