I really need help with this project Not sure what to do Ple

I really need help with this project. Not sure what to do. Please, help me!

Project 1 For our first project we are focusing on selection, e.g. making choices in a program. So I\'ve written a skeleton program you should use to get started and then you add in your code to do the computation and output. Details The skelelun code is sled below and is explained in lhe cummerils in the code. Ir you ave quesliuns aboul whal il does, please ask. Your job is to use the variables that are provided and add any that you need to play the game of Blackjack also called 21. The basic idea is cards are \"drawn\", or in our case, read from a file, and added to a sum. The player will stop playing when their sum equals 17 or greater. If the sum is over 21, then the player has busted and can not win the game. After the first player has played and gotten their final sum the dealer, or player 2, will draw cards until their sum is equal to 17 or greater. After both players have finished drawing cards the winner, if there is one, will be determined. The winner is the player with the highest score but under 22. If both players have the same score it is known as a push game and if both players bust, then no one wins. See the output section tor more cletails. Input

Solution

I am providing the blackjack method for computation of the result according to guidelines above. I have commented the code the best way possible so that its easy to understand, but since I don\'t know the Comment Guidelines as mentioned in the question(Canvas) , please change the comments if required, after understanding.

Code:

void blackjack(string inputfilename, string outputfilename)
{
    string card;
  
    ifstream in(inputfilename);
    ofstream out(outputfilename);
  
    in>>card;
  
    //Variable to maintain the sum of cards for player One
    int playerOneSum=0;
    //Variable to maintain the sum of cards for player Two
    int playerTwoSum=0;
  
    out<<\"Player one\'s cards: \";
    while(!in.fail())
    {
        //Variable to store current card value
        int cardValue=0;
        if(card == \"A\")
        {
            cardValue=1;
        }
        else if(card == \"K\" || card == \"Q\" || card == \"J\")
        {
            cardValue=10;
        }
        else
        {
            //std::string method which converts string to int when possible
            //hence converting cards 2-10 to int 2-10
            cardValue=atoi(card.c_str());  
        }
        //If player one\'s sum is still less than 17 add to player one sum
        if(playerOneSum < 17)
        {
            out<<card+\" \";
            if(cardValue == 1){
                //Checking using ternary operator, whether adding 11 busts the player,
                //if yes, we use 1 as ACE or else we use 11 as ACE
                cardValue = (playerOneSum+11)>21 ? 1 : 11;
            }
            playerOneSum += cardValue;
        }
        else
        {
            if(playerTwoSum == 0)
            {
                //First time this block is entered, i.e, switching to player two
                out<<\"\ Player two\'s cards: \";
            }
          
            if(playerTwoSum < 17)
            {
                out<<card+\" \";
                if(cardValue == 1){
                    //Checking using ternary operator, whether adding 11 busts the player,
                    //if yes, we use 1 as ACE or else we use 11 as ACE
                    cardValue = (playerTwoSum+11)>21 ? 1 : 11;
                }
                playerTwoSum += cardValue;
            }
          
            else
            {
                //Player Two\'s sum is also greater that or equal to 17 so we break the loop
                break;
            }
        }
        in>>card;
    }
    out<<\"\ Game Over\ \";
    if((playerOneSum == playerTwoSum) && playerOneSum < 22)
    {
        out<<\"Push\ \";
    }
    else if(playerOneSum > 21 && playerTwoSum > 21)
    {
        out<<\"Everyone Busted\ \";
    }
    else
    {
        string winner = \"\";
        if(playerOneSum<22 && playerTwoSum<22)
        {
            winner = (playerOneSum>playerTwoSum) ? \"Player one \" : \"Player two \";
        }
        else
        {
            winner = (playerOneSum<22) ? \"Player one \" : \"Player two \";
        }
        out<<winner+\"won\ \";
    }
    out<<\"Player one sum: \"+playerOneSum;
    out<<\"\ Player two sum: \"+playerTwoSum;
    in.close();
    out.close();
}

I really need help with this project. Not sure what to do. Please, help me! Project 1 For our first project we are focusing on selection, e.g. making choices in
I really need help with this project. Not sure what to do. Please, help me! Project 1 For our first project we are focusing on selection, e.g. making choices in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site