Roulette and Cards Project

//Project 2

#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

main()
{
int game, i, b, r, d, choice, draws, card, probability, spins, color, something, number, wnumber, again, evenodd, numbre1, numbre2;
int array[38], evenodd[] = { 0, 0, 0, 0 }, cards[52], color[] = { 0, 0, 0 };
int oddeven;
char heart = 3, diamond = 4, clover = 5, spade = 6;
for (int x = 0; x<38; x++)
{
array[x] = 0;
}
for (int y = 0; y<52; y++)
{
array[y] = 1;
}
int randomNumber(int d);
{
srand((unsigned)time(0));
d = (rand() % 14);
}

const string deck[13] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
std:(deck, deck + 13);

cout << "Which game would you like to play?" << '\n';
cout << "1 - Spin the Roulette Wheel" << '\n';
cout << "2 - Draw Cards" << '\n';
cin >> game;
switch (game)
{
case 1: //roulette
cout << "You have chosen to spin the roulette wheel." << '\n';
choice = 1;
break;
case 2: //cards
cout << "You have chosen to draw cards." << '\n';
choice = 2;
break;
default:
choice = 3;
break;
}

if (choice == 1)
{
cout << "Which probability would you like to see?" << '\n';
cout << "1 - Color" << '\n';
cout << "2 - Number" << '\n';
cout << "3 - Odds and Evens" << '\n';
cin >> probability;
switch (probability)
{
case 1: //color
cout << "You have chosen to see the probability of colors." << '\n';
cout << "How many times would you like to spin the roulette wheel? ";
cin >> spins;
for (int i = 1; i <= spins; i++)
{
number = rand() % 37;
}
cout << "Which color would you like to choose?" << '\n';
cout << "1 - Red" << '\n';
cout << "2 - Black" << '\n';
cout << "3 - Green" << '\n';
cin >> color;
switch (color)
{
case 1: //red
for (int r = 1; r < 0; r = r + 2)
{
r = rand() % 18 + 1;
}
cout << "Red was spun " << ((float)r/(float)spins)*100 << "% of the time." << '\n';
break;
case 2: //black
for (int b = 1; b < 0; b = b + 2)
{
b = rand() % 18 + 1;
}
cout << "Black was spun " << ((float)b/(float)spins)*100 << "% of the time." << '\n';
break;
case 3: //green
if (g == "00" || "0")
{
cout << "Green was spun " << (1 / 38) * 100 << "% of the time." << '\n';
}
else if (g == "00" && g == "0")
{
cout << "Green was spun " << (2 / 38) * 100 << "% of the time." << '\n';
}
break;
default:
cout << "Pleast insert a valid choice." << '\n';
return 0;
break;
}
cout << "Would you like to see the probabilities again?" << '\n';
cout << "1 - Continue" << '\n';
cout << "Anything else - Quit" << '\n';
cin >> again;
switch (again)
{
case 1: //again
cout << "How many times would you like to spin the roulette wheel? ";
cin >> spins;
for (int i = 1; i <= spins; i++)
{
number = rand() % 37;
}
cout << "Which color would you like to choose?" << '\n';
cout << "1 - Red" << '\n';
cout << "2 - Black" << '\n';
cout << "3 - Green" << '\n';
cin >> color;
switch (color)
{
case 1: //red
for (int r = 1; r < 0; r = r + 2)
{
r = rand() % 18 + 1;
}
cout << "Red was spun " << ((float)r / (float)spins) * 100 << "% of the time." << '\n';
break;
case 2: //black
for (int b = 1; b < 0; b = b + 2)
{
b = rand() % 18 + 1;
}
cout << "Black was spun " << ((float)b / (float)spins) * 100 << "% of the time." << '\n';
break;
case 3: //green
if (g == "00" || "0")
{
cout << "Green was spun " << (1 / 38) * 100 << "% of the time." << '\n';
}
else if (g == "00" && g == "0")
{
cout << "Green was spun " << (2 / 38) * 100 << "% of the time." << '\n';
}
break;
default:
cout << "Pleast insert a valid choice." << '\n';
return 0;
break;
}
break;
default:
cout << "Please insert a valid choice." << '\n';
break;
}
break;
case 2: //number
cout << "You have chosen to see the probability of numbers." << '\n';
cout << "How many times would you like to spin the roulette wheel? ";
cin >> spins;
for (int i = 1; i <= spins; i++)
{
number = rand() % 37;
if (number == 0)
{
cout << "00" << '\n';
}
else
{
cout << number - 1 << '\n';
}
array[number] = array[number] + 1;
}
cout << "Which number's probability would you like to see? ";
cin >> wnumber;
if (wnumber == "00")
{
something = 0;
}
else
{
something = (int)wnumber[1] - 48;
if (wnumber[1] != NULL)
{
something = (something * 10) + (int)wnumber[1] - 48;
}
something++;
}
cout << number << "was spun" << ((float)array[something] / (float)spins) * 100 << "% of the time." << '\n';
cout << "Would you like to see a probability again?" << '\n';
cout << "1 - Continue" << '\n';
cout << "Anything else - Quit" << '\n';
cin >> again;
switch (again)
{
case 1: //continue
while (again == 1)
{
cout << "Which number's probability would you like to see? ";
cin >> number;
if (number == "00")
{
something = 0;
}
else
{
something = (int)number[1] - 48;
if (number[1] != NULL)
{
something = (something * 10) + (int)number[1] - 48;
}
something++;
}
cout << number << " was spun " << ((float)array[something] / (float)spins) * 100 << "% of the time." << '\n';
}
default:
cout << "Please insert a valid choice." << '\n';
}
break;
case 3: //odds and evens
cout << "You have chosen to see the probability of odds and evens." << '\n';
cout << "How many times would you like to spin the Roulette Wheel? ";
cin >> spins;
cout << "Which probability would you like to see?" << '\n';
cout << "1- Evens" << '\n';
cout << "2 - Odds" << '\n';
cin >> evenodd;
switch (evenodd)
{
number = rand() % 37;
if ( number == "1", "13", "3", "15", "5", "17", "7", "11", "9", "35", "33", "21", "31", "19", "29", "27", "25")
{
numbre1 = rand() % 17;
cout << "Odds was spun " << ((float)numbre1 / (float)spins) * 100 << "% of the time." << '\n';

}
if (number == "00", "0", "36", "24", "34", "32", "20", "30", "26", "2", "14", "4", "10", "6", "18", "8", "12", "16")
{
numbre2 = rand() % 18;
cout << "Evens was spun " << ((float)numbre2 / (float)spins) * 100 << "% of the time." << '\n';
}
}
break;
default:
cout << "Please insert a valid choice." << '\n';
return 0;
break;
}
}

if (choice == 2)
{
cout << "How many times would you like to draw cards? ";
cin >> draws;
while (i <= 52)
{
int card = randomNumber(card);
if (card == 14) cout << "A ";
else if (card == 13) cout << "K ";
else if (card == 12) cout << "Q ";
else if (card == 11) cout << "J ";
else cout << card << " ";
i++;
}
}

if (choice == 3)
{
cout << "Please insert a valid choice." << '\n';
return 0;
}
return 0;
}
//Can I have help to make this better or help me with the colors and evens and odds and cards part? I don't understand it.
Last edited on
Topic archived. No new replies allowed.