I need to generate 3 random numbers between 2 and 7 and that part is okay. Now my if else statements are not working because I don't know how to use that random value to calculate the winnings. Also for some reason, my else statement which is supposed to be "you lost" is not working because I missed {} when I did not, its right there. And also, I need the program to automatically keep on going in the slot machine until you lose the game and that is not working either.
Full Code
#include <iostream>
#include <ctime>
#include <random>
using namespace std;
int main()
{
int options = 0;
std::cout << "Your Balance: 2000$" << endl;
int bet = 2000;
std::cout << endl;
string op1 = "Press 1: Play slots ";
std::cout << op1 << endl;
string op2 = "Press 2: Check Credits";
std::cout << op2 << endl;
string op3 = "Press 3: End Game";
std::cout << op3 << endl;
std::cout << endl;
std::cin >> options;
std::cout << endl;
bool YN = true;
if (options == 1)
{
std::cout << "Let's Play!";
std::cout << endl;
std::cout << "Enter Bet: ";
std::cin >> bet;
while (bet <= 2000)
{
std::cout << endl;
int game_num = 0;
std::random_device real_random;
std::mt19937 gen(real_random());
std::uniform_int_distribution<> distrib(2, 7);
for (int i = 0; i < 3; i++)
std::cout << distrib(gen);
if (777)
{
bet = bet * 10;
std::cout << "You Won: " << bet << endl;
return 0;
}
else if (222 || 333 || 444 || 555 || 666)
{
bet = bet * 5;
std::cout << "You Won: " << bet << endl;
return 0;
}
else if (223 || 224 || 225 || 226 || 227 || 332 || 334 || 335 || 336 || 337 || 442 || 443 || 445 || 446 || 447 || 552 || 553 || 554 || 556 || 557 || 662 || 663 || 664 || 665 || 667);
{
bet = bet * 3;
std::cout << "You Won: " << bet << endl;
return 0;
}
// This is the else statement that is not working
else
{
std::cout << "You lost" << endl;
}
}
}
else if (options == 2)
{
std::cout << bet;
}
else if (options == 3)
{
std::cout << "Game Over";
}
else
{
std::cout << "!!Please enter a valid option!!";
}
int Y_N;
cout << "Would you like to continue? 1 = Yes, 2 = No" << endl;
cin >> Y_N;
if (Y_N == 2)
YN = false;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire