subject
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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:50
Explain why it is reasonable to assume that receiving 3 duplicate acks in tcp is an indication that the network is not currently congested.
Answers: 1
question
Computers and Technology, 22.06.2019 16:20
It policy compliance and emerging technologies respond to the following: propose at least three control measures that organizations need to put in place to ensure that they remain complaint with emerging technologies and in a continually changing it environment. examine the correlation of effective configuration management and change control procedures to remain compliant with emerging technologies and it security changes.
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
question
Computers and Technology, 24.06.2019 11:30
What does the https: // mean when you type in a website
Answers: 1
You know the right answer?
Use c++
this assignment is a review of loops. do not use anything more advanced than a loop,...
Questions
question
Mathematics, 24.11.2019 02:31
question
History, 24.11.2019 02:31
question
Mathematics, 24.11.2019 02:31
question
Mathematics, 24.11.2019 02:31
question
English, 24.11.2019 02:31
question
Social Studies, 24.11.2019 02:31
question
Mathematics, 24.11.2019 02:31
Questions on the website: 13722367