Well neither of the changes to the while seem to make a difference.
Here is all the code:
Code:
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
int balance = 100;
int bet;
int min = 2;
int max = 12;
int min2 = 1;
int max2= 4;
int win;
int winnings;
string stopch;
string horse;
string winner;
string winner2;
bool keepgoing = false;
cout<<"Welcome to Horse Pundit V1.0"<<endl;
cout<<endl;
do {
srand(time(NULL));
a = (rand() % (max - min + 1) + min);
b = (rand() % (max - min + 1) + min);
c = (rand() % (max - min + 1) + min);
d = (rand() % (max - min + 1) + min);
cout<<"Your balance is "<<char(156)<<balance<<endl;
cout<<endl;
cout <<"Odds...."<<endl;
cout<<endl;
cout<<"Black Beauty: "<<a<<"/1"<<endl;
cout<<"Red Rum: "<<b<<"/1"<<endl;
cout<<"Green Goddess: "<<c<<"/1"<<endl;
cout<<"Silver Speedy: "<<d<<"/1"<<endl;
cout<<endl;
while ( horse != "black beauty" || horse != "Black Beauty" || horse != "red rum" || horse != "Red Rum" || horse != "Green Goddess" || horse != "green goddess" || horse != "Silver Speedy" || horse != "silver speedy") {
cout<<"Please choose your horse: ";
getline (cin, horse);
cout<<endl;
if (horse == "black beauty" || horse == "Black Beauty" || horse == "red rum" || horse == "Red Rum" || horse == "Green Goddess" || horse == "green goddess" || horse == "Silver Speedy" || horse == "silver speedy") {
break;
}
else {
cout<<"That is not a correct horsename!"<<endl;
cout<<endl;
}
}
while ( bet > balance ) {
cout<<"Please enter the amount you would like to bet on "<<horse<<": £";
cin>>bet;
cout<<endl;
if ( bet < balance || bet == balance ) {
break;
}
else {
cout<<"You don't have enough money to bet that amount!"<<endl;
cout<<endl;
}
}
cout<<"Please wait while the race takes place..."<<endl;
cout<<endl;
system ("PAUSE");
win = (rand() % (max2 - min2 + 1) + min);
switch (win)
{
case 1:
winner = "black beauty";
winner2 = "Black Beauty";
winnings = a * bet;
break;
case 2:
winner = "red rum";
winner2 = "Red Rum";
winnings = b * bet;
break;
case 3:
winner = "green goddess";
winner2 = "Green Goddess";
winnings = c * bet;
break;
case 4:
winner = "silver speedy";
winner2 = "Silver Speedy";
winnings = d * bet;
break;
}
if (horse == winner || horse == winner2) {
cout<<"Congratulations, "<<horse<<" won the race!"<<endl;
cout<<endl;
cout<<"You have won £"<<winnings<<endl;
balance = balance + winnings;
cout<<endl;
cout<<"Your balance is now £"<<balance<<endl;
cout<<endl;
cout<<"Would you like to play again?(Y/N): ";
getline (cin, stopch);
if (stopch == "n" || stopch == "N") {
break;
}
else {
system ("CLS");
keepgoing = true;
}
}
else {
cout<<"Sorry, "<<horse<<" lost."<<endl;
cout<<endl;
balance = balance - bet;
cout<<"Your balance is now £"<<balance<<endl;
cout<<endl;
cout<<"Would you like to play again?(Y/N): ";
getline (cin, stopch);
if (stopch == "n" || stopch == "N") {
break;
}
else {
system ("CLS");
keepgoing = true;
}
}
} while (keepgoing);
return 0;
}