Code:
#include <stdlib.h>
#include <stdio.h>
#include <ctime>
#include <string>
#include <iostream>
using namespace std;
int main()
{
srand ( time(NULL) );
string face;
int suit,yes,r;
r = rand()% 10+4;
cout << r;
cout << "hello welcome to a virtual card trick.\n";
cout << "what suit do you want to see it with?\n";
cout << "1 for spades\n 2 for clubs\n 3 for diamonds\n 4 for hearts\n";
cin >> suit;
switch(suit)
{
case(1):
cout << "you choose spades. do you want to use spades? 1 for yes\n 2 for no\n";
cin >> yes;
switch(yes)
{
case(1):
/*if(r=1){
face ="Ace";
}
if(r=11){
face="Jack";
}
if(r=12){
face="Queen";
}
if(r=13){
face="King";
}*/
/*if(r=1)
{
cout << "your card is " << face;
cout << "";
}
if(r>10){cout << "your card is " << face;
cout << "";
}*/
if(1<r<=10){
cout << "your card is " << r;
cout << "";
}
case(2):
cout << "start program over to try again\n";
system("pause");
return 0;
}
case(2):
cout << "you choose clubs. do you want to use clubs? 1 for yes\n 2 for no\n";
cin >> yes;
switch(yes)
{
case(1):
if((r=1)||(r>10))
{
cout << "your card is " << face;
cout << "";
}
else{
cout << "your card is " << r;
cout << "";
}
case(2):
cout << "start program over to try again\n";
system("pause");
return 0;
}
case(3):
cout << "you choose diamonds. do you want to use diamonds? 1 for yes\n 2 for no\n";
cin >> yes;
switch(yes)
{
case(1):
if((r=1)||(r>10))
{
cout << "your card is " << face;
cout << "";
}
else{
cout << "your card is " << r;
cout << "";
}
case(2):
cout << "start program over to try again\n";
system("pause");
return 0;
}
case(4):
cout << "you choose hearts. do you want to use hearts? 1 for yes\n 2 for no\n";
cin >> yes;
switch(yes)
{
case(1):
if((r=1)||(r>10))
{
cout << "your card is " << face;
cout << "";
}
else{
cout << "your card is " << r;
cout << "";
}
case(2):
cout << "start program over to try again\n";
system("pause");
return 0;
}
}
}
Comment