I'm a total beginner. Please review my code and also help me to improve it.
I want a slot machine with: 1000$ to start with. It's seems to be working. Please help me to make it more simpler.
// A Slotting Machine implementation
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int Random(int low, int high);
int main()
{
int low = 2; // Random number range.
int high = 7; // Random number range.
int r0, r1, r2;
int money = 1000; // Initial money to start with.
int reply = 0;
char exit;
int bet;
char restart;
char cont;
srand( time (0) ); // Default Random Number function call.
cout << "Players chips: $1000"<< endl;
while(true)
{
cout << "1) Play slot. 2) Exit. ";
cin >> reply;
if(reply == 1)
{
while(1)
{
while(true)
{
cout << "Enter your bet: ";
cin >> bet;
if(bet > 0 && bet <= money)
break;
else cout << "Please enter a valid bet.\n";
}
r0 = Random(low, high); // Function call
cout << r0 <<" ";
r1 = Random(low, high); // Function call
cout << r1 << " ";
r2 = Random(low, high); // Function call
cout << r2 << endl;
if (r0 == r1 == r2 == 7) // Machine's number sequence.
{
money = (10 * bet);
cout << "Lucky Bucky!\n";
cout << "Players chips: $" << money << endl;
}
if((r0 == r1 == r2) && (r0 != 7 && r1 != 7 && r2 != 7)) // Machine's number sequence.
{
money = (5 * bet);
cout << "Not Bad!\n";
cout << "Players chips: $" << money << endl;
}
if(r0 == r1 || r1 == r2 || r0 == r2) // Machine's number sequence.
{
money = (3 * bet);
cout << "Go Happy!\n";
cout << "Players chips: $" << money << endl;
}
else
{ cout << "You Lose!\n";
money -= bet; // Get Previous amount back.
cout << "Your Money: " << money << endl;
if(money == 0)
{
cout << "You just got flushed!\n";
cout << "Exiting...\n";
break;
}
}
cout << "1) Play slot. 2) Exit. ";
cin >> cont;
if(cont == '1')
continue;
else cout << "Exiting\n";
break;
}
}
else if (reply == 2)
cout << "Exiting\n";
break;
}
}
int Random(int low, int high)
{
int r0 = low + rand() % ((high + 1) - low);
return r0;
int r1 = low + rand() % ((high + 1) - low);
return r1;
int r2 = low + rand() % ((high + 1) - low);
return r2;
}