I've developed a slot machine game. It is perfect now except for 1 thing, the random numbers don't change. Have you got any advice?
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand(time(0));
int num1=rand()%10+1;
srand(time(0));
int num2=rand()%10+1;
srand(time(0));
int num3=rand()%10+1;
int coins=10;
cout<<"---------------------------------------------------------------------"<<endl;
cout<<" Welcome to slot machine"<<endl;
cout<<" You have 10 coins"<<endl;
cout<<" If all 3 numbers that appear are the same, you get 10 coins"<<endl;
cout<<" If 2 numbers are the same, you get 3 coins"<<endl;
cout<<" If all 3 numbers are different, you lose 1 coin"<<endl;
cout<<" Hit enter to play"<<endl;
cout<<"---------------------------------------------------------------------"<<endl;cin.get();
cout<<""<<endl;
while(coins<100)
{
cout<<num1<<" "<<num2<<" "<<num3<<" "<<endl;
if(coins<1)
{
coins=coins+10;
cout<<"You are bankrupt, your money is reset. You now have "<<coins<<endl;
cout<<"coins"<<endl;
}
else if(num1==num2&&num1==num3)
{
coins=coins+10;
cout<<"You got the jackpot. You now have "<<coins<<" coins"<<endl;cin.get();
}
else if(num1==num3||num1==num2||num2==num3)
{
coins=coins+3;
cout<<"You won 3 coins. You now have "<<coins<<" coins"<<endl;cin.get();
}
else
{
coins=coins-1;
cout<<"You lose 1 coin. You now have "<<coins<<" coins"<<endl;
}
}
cout<<"You have won the game. Congratulations.";cin.get();
return 0;
}