#include #include #include #include #include #define spade 06#define

#include #include #include

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

h>#include #include #define spade 06#define club 05#define diamond 04#define heart 03#define RESULTS “Blackjack.txt”int k;int l;int d;int won;int loss;int cash=500;int bet;int randomcard;int playertotal=0;int dealertotal;int clubcard();int diamondcard();int heartcard();int spadecard();int randcard();int betting();void asktitle();void rules();void play();void dealer();void stay();void cash_test();void askover();void fileresults();int main(void){    char choice_1;    printf(“”);    printf(“%c%c%c%c%c     %c%c            %c%c         %c%c%c%c%c    %c    %c                “, club, club, club, club, club, spade, spade, diamond, diamond, heart, heart, heart, heart, heart, club, club);    printf(“%c    %c    %c%c           %c  %c       %c     %c   %c   %c              “, club, club, spade, spade, diamond, diamond, heart, heart, club, club);    printf(“%c    %c    %c%c          %c    %c     %c          %c  %c               “, club, club, spade, spade, diamond, diamond, heart, club, club);    printf(“%c%c%c%c%c     %c%c          %c %c%c %c     %c          %c %c              “, club, club, club, club, club, spade, spade, diamond, diamond, diamond, diamond, heart, club, club);    printf(“%c    %c    %c%c         %c %c%c%c%c %c    %c          %c%c %c             “, club, club, spade, spade, diamond, diamond, diamond, diamond, diamond, diamond, heart, club, club, club);    printf(“%c     %c   %c%c         %c      %c    %c          %c   %c               “, club, club, spade, spade, diamond, diamond, heart, club, club);    printf(“%c     %c   %c%c        %c        %c    %c     %c   %c    %c             “, club, club, spade, spade, diamond, diamond, heart, heart, club, club);    printf(“%c%c%c%c%c%c    %c%c%c%c%c%c%c   %c        %c     %c%c%c%c%c    %c     %c            “, club, club, club, club, club, club, spade, spade, spade, spade, spade, spade, spade, diamond, diamond, heart, heart, heart, heart, heart, club, club);    printf(”               KAAYATHRI SUBRAMANIAM “);    printf(”     %c%c%c%c%c%c%c%c      %c%c         %c%c%c%c%c    %c    %c                “, diamond, diamond, diamond, diamond, diamond, diamond, diamond, diamond, heart, heart, club, club, club, club, club, spade, spade);    printf(”        %c%c        %c  %c       %c     %c   %c   %c              “, diamond, diamond, heart, heart, club, club, spade, spade);    printf(”        %c%c       %c    %c     %c          %c  %c               “, diamond, diamond, heart, heart, club, spade, spade);    printf(”        %c%c       %c %c%c %c     %c          %c %c              “, diamond, diamond, heart, heart, heart, heart, club, spade, spade);    printf(”        %c%c      %c %c%c%c%c %c    %c          %c%c %c             “, diamond, diamond, heart, heart, heart, heart, heart, heart, club, spade, spade, spade);    printf(”        %c%c      %c      %c    %c          %c   %c               “, diamond, diamond, heart, heart, club, spade, spade);    printf(”     %c  %c%c     %c        %c    %c     %c   %c    %c             “, diamond, diamond, diamond, heart, heart, club, spade, spade,spade);    printf(”      %c%c%c      %c        %c     %c%c%c%c%c    %c     %c            “, diamond, diamond, diamond, heart, heart, club, club, club, club, club, spade, spade);    printf(“”);    asktitle();    printf(“”);    printf(“”);    system(“pause”);    return(0);}void asktitle(){    char choice_1;    int  choice_2;     printf(”                 Are You Ready?”);     printf(”                —————-“);     printf(”                      (Y/N)                        “);     scanf(“%c”,&choice_1);    while((choice_1!=’Y’) && (choice_1!=’N’) && (choice_1!=’y’) && (choice_1!=’n’))    {        printf(“”);        printf(“INVALID Choice. Please Enter Y for Yes or N for No.”);        scanf(“%c”,&choice_1);    }    if((choice_1 == ‘Y’) || (choice_1 == ‘y’))    {            system(“cls”);            printf(“Enter 1 to Begin the Greatest Game Ever Played.

“);            printf(“Enter 2 to See a Complete Listing of Rules.”);            printf(“Enter 3 to Exit Game. (Not Recommended)”);            printf(“Choice: “);            scanf(“%d”, & choice_2);            if(( choice_2<1) || ( choice_2>3))            {                printf(“Incorrect Choice. Please enter 1, 2 or 3”);                scanf(“%d”, & choice_2);            }            switch( choice_2)            {                case 1:                   system(“cls”);                   play();                   break;                case 2:                   system(“cls”);                   rules();                   break;                case 3:                   printf(” HAVE A GREAT DAY.

“);                   printf(“Have an almost perfect day!”);                   system(“pause”);                   exit(0);                   break;                default:                   printf(“Invalid Input”);            }    }    else if((choice_1 == ‘N’) || (choice_1 == ‘n’)) // If no, exit program    {        printf(“Your day could have been perfect.”);        printf(“Have an almost perfect day!”);        system(“pause”);        exit(0);    }    return;}void rules(){     char choice_1;     int   choice_2;     printf(”           RULES OF BLACKJACK”);     printf(”          —————————“);     printf(“I.”);     printf(”       Ought not scrutinize the chances of this GAME .”);     printf(”      %c This program produces cards indiscriminately “, spade);     printf(”      %c On the off chance that you continue losing, you are exceptionally unfortunate “, diamond);     printf(“II.

“);     printf(”     Each card has a value.”);     printf(”      %c Number cards 1 to 10 hold an estimation of their number..”, spade);     printf(”      %c  J, Q, and K cards hold an estimation of 10.”, diamond);     printf(”      %c Ace cards hold a value of 11″, club);     printf(”     The objective of this GAME is to achieve a card esteem aggregate of 21.”);     printf(“III.”);     printf(”     After the managing of the initial two cards, YOU should choose whether to HIT or STAY.”);     printf(”      %c taying will guard you, hitting will include a card”, spade);     printf(”     Because you are competing against the dealer, you must beat his hand.

“);     printf(”     BUT BEWARE!.”);     printf(”      %c If your total goes over 21, you will LOSE!.”, diamond);     printf(”     But the world is not over, because you can always play again.”);     printf(“%c%c%c YOUR RESULTS ARE RECORDED AND FOUND IN SAME FOLDER AS PROGRAM %c%c%c”, spade, heart, club, club, heart, spade);     printf(“Would you like to go the previous screen? (I will not take NO for an answer)”);     printf(”                  (Y/N)                    “);     scanf(“%c”,&choice_1);     while((choice_1!=’Y’) && (choice_1!=’y’) && (choice_1!=’N’) && (choice_1!=’n’))    {        printf(“”);        printf(“INVALID Choice. Please Enter Y for Yes or N for No.

“);        scanf(“%c”,&choice_1);    }     while((choice_1!=’Y’) && (choice_1!=’y’) && (choice_1!=’N’) && (choice_1!=’n’))    {        printf(“”);        printf(“INVALID Choice. Please Enter Y for Yes or N for No.”);        scanf(“%c”,&choice_1);    }    if((choice_1 == ‘Y’) || (choice_1 == ‘y’))    {            system(“cls”);            asktitle();    }    else if((choice_1 == ‘N’) || (choice_1 == ‘n’))    {        system(“cls”);        printf(”                 I told you so.”);        asktitle();    }    return;} // End functionint clubcard(){    srand((unsigned) time(NULL));    k=rand()%13+1;    if(k<=9)    {    printf("-------");    printf("|%d    |", club);    printf("|  %d  |", k);    printf("|    %d|", club);    printf("-------");    }    if(k==10)    {    printf("________");    printf("|%c    |", club);    printf("|  J   |");    printf("|    %c|", club);    printf("________");    }    if(k==11)    {    printf("-------");    printf("|%c    |", club);    printf("|  A   |");    printf("|    %c|", club);    printf("-------");    if(playertotal<=10)         {             k=11;         }         else         {             k=1;         }    }    if(k==12) //If  number is 12, print card with Q (Queen) on face    {    //Club Card    printf("-------");    printf("|%c    |", club);    printf("|  Q   |");    printf("|    %c|", club);    printf("-------");    k=10; //Set card value to 10    }    if(k==13) //If  number is 13, print card with K (King) on face    {    //Club Card    printf("-------");    printf("|%c    |", club);    printf("|  K   |");    printf("|    %c|", club);    printf("-------");    k=10; //Set card value to 10    }    return k;}// End functionint diamondcard() //Displays Diamond Card Image{    srand((unsigned) time(NULL)); //Generates  seed for rand() function    k=rand()%13+1;    if(k<=9) //If  number is 9 or less, print card with that number    {    //Diamond Card    printf("-------");    printf("|%c    |", diamond);    printf("|  %d  |", k);    printf("|    %c|", diamond);    printf("-------");    }    if(k==10) //If  number is 10, print card with J (Jack) on face    {    //Diamond Card    printf("-------");    printf("|%c    |", diamond);    printf("|  J   |");    printf("|    %c|", diamond);    printf("-------");    }    if(k==11) //If random number is 11, print card with A (Ace) on face    {    //Diamond Card    printf("-------");    printf("|%c    |", diamond);    printf("|  A   |");    printf("|    %c|", diamond);    printf("-------");    if(playertotal<=10) //If  number is Ace, change value to 11 or 1 depending on dealer total         {             k=11;         }         else         {             k=1;         }    }    if(k==12) //If  number is 12, print card with Q (Queen) on face    {    //Diamond Card    printf("________");    printf("|%c    |", diamond);    printf("|  Q   |");    printf("|    %c|", diamond);    printf("________");    k=10; //Set card value to 10    }    if(k==13) //If  number is 13, print card with K (King) on face    {    //Diamond Card    printf("-------");    printf("|%c    |", diamond);    printf("|  K   |");    printf("|    %c|", diamond);    printf("-------");    k=10; //Set card value to 10    }    return k;}// End functionint heartcard() //Displays Heart Card Image{    srand((unsigned) time(NULL)); //Generates random seed for rand() function    k=rand()%13+1;    if(k<=9) //If random number is 9 or less, print card with that number    {    //Heart Card    printf("-------");    printf("|%c    |", heart);    printf("|  %d  |", k);    printf("|    %c|", heart);    printf("-------");    }    if(k==10) //If random number is 10, print card with J (Jack) on face    {    //Heart Card    printf("-------");    printf("|%c    |", heart);    printf("|  J   |");    printf("|    %c|", heart);    printf("-------");    }    if(k==11) //If random number is 11, print card with A (Ace) on face    {    //Heart Card    printf("-------");    printf("|%c    |", heart);    printf("|  A   |");    printf("|    %c|", heart);    printf("-------");    if(playertotal<=10) //If random number is Ace, change value to 11 or 1 depending on dealer total         {             k=11;         }         else         {             k=1;         }    }    if(k==12) //If random number is 12, print card with Q (Queen) on face    {    //Heart Card    printf("-------");    printf("|%c    |", heart);    printf("|  Q   |");    printf("|    %c|", heart);    printf("-------");    k=10; //Set card value to 10    }    if(k==13) //If random number is 13, print card with K (King) on face    {    //Heart Card    printf("-------");    printf("|%c    |", heart);    printf("|  K   |");    printf("|    %c|", heart);    printf("-------");    k=10; //Set card value to 10    }    return k;} // End Functionint spadecard() //Displays Spade Card Image{    srand((unsigned) time(NULL)); //Generates random seed for rand() function    k=rand()%13+1;    if(k<=9) //If random number is 9 or less, print card with that number    {    //Spade Card    printf("-------");    printf("|%c    |", spade);    printf("|  %d  |", k);    printf("|    %c|", spade);    printf("-------");    }    if(k==10) //If random number is 10, print card with J (Jack) on face    {    //Spade Card    printf("-------");    printf("|%c    |", spade);    printf("|  J   |");    printf("|    %c|", spade);    printf("-------");    }    if(k==11) //If random number is 11, print card with A (Ace) on face    {    //Spade Card    printf("-------");    printf("|%c    |", spade);    printf("|  A   |");    printf("|    %c|", spade);    printf("-------");    if(playertotal<=10) //If random number is Ace, change value to 11 or 1 depending on dealer total         {             k=11;         }         else         {             k=1;         }    }    if(k==12) //If random number is 12, print card with Q (Queen) on face    {    //Spade Card    printf("-------");    printf("|%c    |", spade);    printf("|  Q   |");    printf("|    %c|", spade);    printf("-------");    k=10; //Set card value to 10    }    if(k==13) //If random number is 13, print card with K (King) on face    {    //Spade Card    printf("-------");    printf("|%c    |", spade);    printf("|  K   |");    printf("|    %c|", spade);    printf("-------");    k=10; //Set card value to 10    }    return k;} // End Functionint randcard() //Generates random card{     srand((unsigned) time(NULL)); //Generates random seed for rand() function     randomcard = rand()%4+1;     if(randomcard==1)     {         clubcard();         l=k;     }     if(randomcard==2)     {         diamondcard();         l=k;     }     if(randomcard==3)     {         heartcard();         l=k;     }     if(randomcard==4)     {         spadecard();         l=k;     }     return l;} // End Functionvoid play() //Plays game{     int p=0; // holds value of player_total     int i=1; // counter for asking user to hold or stay (aka game turns)     char choice3;     cash_test();     printf("Cash: $%d",cash); //Prints amount of cash user has     randcard(); //Generates random card     playertotal = p + l; //Computes player total     p = playertotal;     printf("Your Total is %d", p); //Prints player total     dealer(); //Computes and prints dealer total     betting(); //Prompts user to enter bet amount     while(i<=21) //While loop used to keep asking user to hit or stay at most twenty-one times                  //  because there is a chance user can generate twenty-one consecutive 1's     {         if(p==21) //If user total is 21, win         {             printf("! Awesome You Win!");             won = won+1;             cash = cash+bet;             printf("You have %d Wins and %d Losses. Awesome!", won, loss);             dealertotal=0;             askover();         }         if(p>21) //If player total is over 21, loss         {             printf(“WOWWWW Buddy, You Went WAY over.

“);             loss = loss+1;             cash = cash – bet;             printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);             dealertotal=0;             askover();         }         if(p<=21) //If player total is less than 21, ask to hit or stay         {             printf("Would You Like to Hit or Stay?");             scanf("%c", );             while((choice3!='H') && (choice3!='h') && (choice3!='S') && (choice3!='s')) // If invalid choice entered             {                 printf("");                 printf("Please Enter H to Hit or S to Stay.");                 scanf("%c",);             }             if((choice3=='H') || (choice3=='h')) // If Hit, continues             {                 randcard();                 playertotal = p + l;                 p = playertotal;                 printf("Your Total is %d", p);                 dealer();                  if(dealertotal==21) //Is dealer total is 21, loss                  {                      printf("Merchant Has the Better Hand.

You Lose.”);                      loss = loss+1;                      cash = cash – bet;                      printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);                      dealertotal=0;                      askover();                  }                  if(dealertotal>21) //If dealer total is over 21, win                  {                      printf(“Dealer Has Went Over!. You Win!”);                      won = won+1;                      cash = cash+bet;                      printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);                      dealertotal=0;                      askover();                  }             }             if((choice3==’S’) || (choice3==’s’)) // If Stay, does not continue             {                printf(“You Have Chosen to Stay at %d. Wise Decision!”, playertotal);                stay();             }          }             i++; //While player total and dealer total are less than 21, re-do while loop     } // End While Loop} // End Functionvoid dealer() //Function to play for dealer AI{     int z;     if(dealertotal<17)     {      srand((unsigned) time(NULL) + 1);      z=rand()%13+1;      if(z<=10)      {         d=z;      }      if(z>11)      {         d=10;      }      if(z==11)      {         if(dealertotal<=10)         {             d=11;         }         else         {             d=1;         }      }     dealertotal = dealertotal + d;     }     printf("The Dealer Has a Total of %d", dealertotal);} // End Functionvoid stay(){     dealer();     if(dealertotal>=17)     {      if(playertotal>=dealertotal)      {         printf(“Unbelievable! You Win!”);         won = won+1;         cash = cash+bet;         printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);         dealertotal=0;         askover();      }      if(playertotal

You Lose.”);         loss = loss+1;         cash = cash – bet;         printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);         dealertotal=0;         askover();      }      if(dealertotal>21)      {         printf(“Unbelievable! You Win!”);         won = won+1;         cash = cash+bet;         printf(“You have %d Wins and %d Losses. Awesome!”, won, loss);         dealertotal=0;         askover();      }     }     else     {         stay();     }} // End Functionvoid cash_test(){     if (cash <= 0)     {        printf("You Are Bankrupt. Diversion Over");        cash = 500;        askover();     }}int betting(){ printf("Enter Bet: $"); scanf("%d", ); if (bet > cash) {        printf(“You can’t wager more cash than you have.”);        printf(“Enter Bet: “);        scanf(“%d”, );        return bet; } else return bet;} // End Functionvoid askover(){    char choice_1;     printf(“Would You Like To Play Again?”);     printf(“Please Enter Y for Yes or N for No”);     scanf(“%c”,);    while((choice_1!=’Y’) && (choice_1!=’y’) && (choice_1!=’N’) && (choice_1!=’n’))    {        printf(“”);        printf(“Incorrect Choice.

Please Enter Y for Yes or N for No.”);        scanf(“%c”,);    }    if((choice_1 == ‘Y’) || (choice_1 == ‘y’))    {            system(“cls”);            play();    }    else if((choice_1 == ‘N’) || (choice_1 == ‘n’))    {        fileresults();        printf(“BYE!!!!”);        system(“pause”);        exit(0);    }    return;}void fileresults(){    FILE *fpresults;    fpresults = fopen(RESULTS, “w”);    if(fpresults == NULL)    {               printf(“Error: File Missing”);               system(“pause”);               exit(1);    }    else    {     fprintf(fpresults,” FINAL RESULTS”);     fprintf(fpresults,” ———“);     fprintf(fpresults,”You  WIN %d Times”, won);     fprintf(fpresults,”You Have Lost %d Times”, loss);     fprintf(fpresults,”Continue Playing and Set an All-Time Record!”);    }     fclose(fpresults);     return;} // End Function