Computers and Technology
Computers and Technology, 09.09.2019 18:10, mari530

Use c++
this assignment is a review of loops. do not use anything more advanced than a loop, such as programmer-defined functions or arrays or classes.
if you know blackjack, you may be tempted to change the specifications below to make the game more "blackjack-like". don't. be sure to follow these specs exactly and don't try to improve on them. you will be penalized if the specs are not met exactly.
in the card game named 'blackjack' players get two cards to start with, and then they are asked whether or not they want more cards. players can continue to take as many cards as they like. their goal is to get as close as possible to a total of 21 without going over. face cards have a value of 10.
write a command line game that plays a simple version of blackjack. the program should generate a random number between 1 and 10 each time the player gets a card. each of the values (1 through 10) must be equally likely. (in other words, this won't be like real black jack where getting a 10 is more likely than getting some other value, because in real black jack all face cards count as 10.) it should keep a running total of the player's cards, and ask the player whether or not it should deal another card. if the player hits 21 exactly, the program should print "congratulations! " and then ask if the player wants to play again. if the player exceeds 21, the program should print "bust" and then ask if the player wants to play again. sample output for the game is written below. your program should produce the same output.
if you'd like a little refresher on random number generation, see lesson 7.3.
> first cards: 3, 2
> total: 5
> do you want another card? (y/n): y
> card: 6
> total: 11
> do you want another card? (y/n): y
> card: 7
> total: 18
> do you want another card? (y/n): n
> would you like to play again? (y/n): y
>
> first cards: 10, 2
> total: 12
> do you want another card? (y/n): y
> card: 6
> total: 18
> do you want another card? (y/n): y
> card: 7
> total: 25
> bust.
> would you like to play again? (y/n): n
suggestion
be sure to use iterative development. start with a small amount of functionality, and then grow it gradually. this way you can compile and run your program after each statement that you write.
you might start by just generating a single card. the program execution might look like this:
> first card: 3
then generate two cards
> first cards: 3, 2
next add a variable to store the total, and a statement to show its value:
> first cards: 3, 2
> total: 5
next read in a user response and print out the value that was entered
> first cards: 3, 2
> total: 5
> do you want another card? (y/n): y
> you entered: y
next you might add a loop, without yet adding the blackjack logic
> first cards: 3, 2
> total: 5
> do you want another card? (y/n): y
> do you want another card? (y/n): y
> do you want another card? (y/n): n
now move the display of the total to the loop
> first cards: 3, 2
> total: 5
> do you want another card? (y/n): y
> total: 5
> do you want another card? (y/n): y
> total: 5
> do you want another card? (y/n): n
your next steps might be something like this:
generate a new card in each loop and display the value
update the total in each loop.
check to see if the user busts in each loop
wrap the game in loop that handles the play-again functionality

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:00, mterzic1
Assume that you have an array of integers named a. which of these code segments print the same results? int i = 1; while(i < a. length) { system. out. println(a[i]); i++; } int i; for (i = 0; i < a. length; i++) { system. out. println(a[i]); } for (int i : a) { system. out. println(i); } i and ii only ii and iii only i and iii only all three print the same results. all three print different results.
Answers: 3
image
Computers and Technology, 22.06.2019 21:00, jennifer7037
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
image
Computers and Technology, 23.06.2019 07:30, cireland
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits. now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order. finally, output thedigits in thearray. use at least two functions to organize your program.
Answers: 3
image
Computers and Technology, 23.06.2019 08:00, seaotter7140
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
Do you know the correct answer?
Use c++
this assignment is a review of loops. do not use anything more advanced than a loop,...

Questions in other subjects: