Random Number Generating - Help!!

The exercise I'm working on right now is this:

Write a program that plays a guessing game where the computer tries to guess a number
picked by the user. The program asks the user to think of a secret number and then asks the
user a sequence of guesses. After each guess, the user must report whether it is too high or
too low or correct. The program should count the guesses. (Hint: Maintain HighestPossible
and LowestPossible variables, and always guess midway between the two. This is called a
binary search.) The program output should look similar to:
Think of a number between 1 and 100 and then press any key.
Is the number 50 (Correct, Low, High)? h
Is the number 25 (Correct, Low, High)? h
Is the number 13 (Correct, Low, High)? l
Is the number 19 (Correct, Low, High)? c
Number of guesses: 4

And I'm currently stuck. I have this code although I'm not entirely sure I'm doing the right thing. Help??

#include "stdafx.h"
#include <iostream>
#include <string>
#include <random>
#include <time.h>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
cout << "Think of a number between 1 and 100." << endl << endl ;

srand((unsigned)time(0)) ;

string answer;
int counter = 0, HighestPossible = 100, LowestPossible = 1, Mid = 0 ;

cout << "Is the number " << rand()%HighestPossible+LowestPossible << " (Correct, Low, High)? " ;
cin >> answer ;

do
{
counter++ ;

while ((answer=="High") || (answer=="H") || (answer=="high") || (answer=="h"))
{
HighestPossible = HighestPossible/1 ;
cout << "Is the number " << rand()%HighestPossible+LowestPossible << " (Correct, Low, High)? " ;
cin >> answer ;
}

while ((answer=="Low") || (answer=="L") || (answer=="low") || (answer=="l"))
{
LowestPossible = LowestPossible*1 ;
cout << "Is the number " << rand()%HighestPossible+LowestPossible << " (Correct, Low, High)? " ;
cin >> answer ;
}



} while ((answer!="Correct")) ;



cout << "Number of guesses: " << counter ;



cin.get();
cin.ignore();
return 0;
}

Could you give me hints or corrections so I can finish this??
closed account (D80DSL3A)
Answer removed due to response timeout.
Last edited on
Topic archived. No new replies allowed.