I cant figure out why my second switch stament is not working. Can you please help? I am still new at this still.
// Project 8.4. Guesses the number the user enters between 1-100.
#include <iostream>
#include <ctime>
using namespace std;
char H,L,Y,N;
int UsersNum, YesNo, HighLow, Re_Use;
int n = 50, lastguess;
int HigherThan = 0, LowerThan =101;
int main ()
{
cout << "Welcome to the number guessing game! \n";
cout << "I will try and guess the number you will enter. \n";
cout << "Please enter a number between 1 - 100. \n";
cin >> UsersNum;
cout << "Is your number 50? Enter 1 for Yes or enter 2 for No. \n";
cin >> YesNo;
switch (YesNo)
{ case 1:
cout << "I guessed your number!\n";
break;
do
{
case 2:
cout << "Higher or lower? \n";
cout << "Enter H for higher or enter L for lower. \n";
cin >> HighLow;
break;
default:
cout << "Invalid entry. \n" ;
break ;
}
switch (HighLow);
{ case 'H':
n =(LowerThan-n) /2 + n;
LowerThan =lastguess;
cout << "Is this your number " <<n<< "? \n";
cout << "Please enter 1 for yes or 2 for no. \n";
cin >> Re_Use;
break;
case 'L':
n =(n-HigherThan)/2 + HigherThan;
HigherThan = lastguess;
cout << "Is this your number " <<n<< "? \n";
cout << "Please enter Y for yes or N for no. \n";
cin >> Re_Use;
break;
default:
cout << "Invalid Entry. \n";
break;
}
if (Re_Use == Y)
return 0;
}
while ( Re_Use == N)
return 0;
}
Errors:
1>------ Build started: Project: project84, Configuration: Debug Win32 ------
1>Compiling...
1>project84.cpp
1>g:\visual studio 2008\projects\project84\project84.cpp(38) : error C2059: syntax error : 'switch'
1>g:\visual studio 2008\projects\project84\project84.cpp(55) : error C2048: more than one default
1>Build log was saved at "file://g:\Visual Studio 2008\Projects\project84\Debug\BuildLog.htm"
1>project84 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========