For clarity's sake,the instructions I was given are as follows:
The program is basically 4 blocks of code. Here is a skeleton of what you will have to do:
•Set a variable like AGAIN to 1 (this variable will control your loops, 1 means it will loop, 0 means it will terminate)
•Use INPUT with a string variable that asks for Yes or No to the question, do you want to play black jack.
•Use an IF statement to check is the user said Yes or NO, if they said Yes, you need to use the INT statement that was given to you in the directions and set it to a variable like PlayerHand and then print out the random value with a statement like “You start with:”;PlayerHand. If the answer is NO, you have to Print a goodbye statement and then tack on :END to that to make the program terminate (be sure to use the colons between the print statement and the End statement)
Now, set up a DO WHILE AGAIN=1 block that contain the following:
•Ask if they want another card with a string variable like Card$
•If Card$ is Yes, then set a numeric variable like Card to the Random INT statement given to you in the program instructions, print out the result and add it to PlayerHand
•Then check PlayerHand to see if it is greater than 21 (with an IF statement) if it is, tell them they are busted and the computer wins, and end the program with :END
• If Card$ is not Yes, then set Again=0
•Print “your Total is”;PlayerHand
•Loop
Set AGAIN to 1 and then Set up another DO WHILE AGAIN=1 block for the dealers hand that looks like this:
•Set a variable like Card to the Random INT statement given in the instructions
•Set a variable like DealerHand to DealerHand + Card
•Check to see if DealerHand is greater than or equal to 16 and Less than or equal to 21, if it is set Again to 0 (so the loop ends)
•Check to see if DealerHand is greater than 21, if it is print a message that the dealer is bust and you win and use :END to terminate the program
•Print “Dealers Hand is:”; DealerHand
•Loop
The last part is to compare PlayerHand and DealerHand:
•If PlayerHand is less than DealerHand, then Print Dealer wins
•If PlayerHand is greater than DealerHand, then Print You win
•If PlayerHand is equal to DealerHand, Print It is a draw.
And this is my program:
again=1 print "Do you want to play blackjack? Enter yes or no."; input answer$ if answer$ = "yes" then let playerhand = int(rnd(1)*10)+1 print "You start with "; playerhand else if answer$ = "no" then print "Goodbye!":end end if end if do while again=1 print "Do you want another card? Enter yes or no." input card$ if card$ = "yes" then let card = int(rnd(1)*10)+1 let playerhand = card+playerhand print "You now have "; playerhand; " in your hand." if playerhand > 21 then print "Busted! You loose. :(/>":end else if card$ = "no" then again=0 print "your total is "; playerhand end if end if end if loop again=1 do while again=1 let card = int(rnd(1)*10)+1 let dealerhand = dealerhand+card if dealerhand >= 16 and dealerhand <= 21 then again=0 if dealerhand > 21 then print "Dealer is bust. You win! :)/>":end else print "Dealer's hand is "; dealerhand end if end if loop if playerhand < dealerhand then print "Dealer wins." else if playerhand > dealerhand then print "You win." else if playerhand = dealerhand then print "It's a draw." end if end if end if end

New Topic/Question
Reply
MultiQuote






|