1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Step2247 [10]
3 years ago
5

Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. (The player decides how ma

ny, but that has no effect on this exercise.) The cards 2 through 10 are scored as 2 through 10 points each. The face cards, jack, queen, and king are scored as 10 points. The goal is to come as close to a score of 21 as possible without going over 21. Hence, any score over 21 is called "busted." The ace can count as either 1 or 11, whichever is better for the user. For example, an ace and a 10 can be scored as either 11 or 21. Since 21 is a better score, this hand is scored as 21. An ace and two 8' s can be scored as either 17 or 27. Since 27 is a "busted" score, this hand is scored as 17.
Computers and Technology
1 answer:
Anastaziya [24]3 years ago
8 0

Answer:

C++ code is explained below

Explanation:

#include <iostream>

using namespace std;

void instructions ( );

void input (int& number_of_cards, char& card_value1, char& card_value2, char& card_value3, char& card_value4, char& card_value5);

int calculate_hand (int& number_of_cards, char& card_value1, char& card_value2, char& card_value3, char& card_value4, char& card_value5);

void output_result ( );

int main ( )

{

char yes;

int number_of_cards;

char card_value1;

char card_value2;

char card_value3;

char card_value4;

char card_value5;

instructions ( );

do{

input (number_of_cards, card_value1, card_value2, card_value3, card_value4, card_value5);

cout << "Again? (y/n)" << endl;

cin >> yes;

cout << endl;

}while (yes == 'Y' || yes == 'y');

system ("Pause");

return 0;

}

void instructions ( )

{

cout << "This program scores a blackjack hand. The user is asked how many cards" << endl;

cout << "he or she has, and the card values. This program will then output the user's" << endl;

cout << "scores. The output will be either: a number between 2 and 21, or the word BUSTED" << endl << endl;

cout << "The values of the cards should be inputted as the following: input the numbers" << endl;

cout << "2-9 just as inputting regular numbers, for the number 10 input 't', for jack" << endl;

cout << "input 'j' for queen input 'q', for king input 'k', and for ace input 'a'" << endl << endl;

}

void input (int& number_of_cards, char& card_value1, char& card_value2, char& card_value3, char& card_value4, char& card_value5)

{

cout << "Please input the number of cards in your hand (either 2, 3, 4, or 5)" << endl;

cin >> number_of_cards;

cout << endl;

if (number_of_cards == 2)

{

cout << "Please input the value of the first card: " << endl;

cin >> card_value1;

cout << "Please input the value of the second card: " << endl;

cin >> card_value2;

cout << endl << endl;

}

else if (number_of_cards == 3)

{

cout << "Please input the value of the first card: " << endl;

cin >> card_value1;

cout << "Please input the value of the second card: " << endl;

cin >> card_value2;

cout << "Please input the value of the third card: " << endl;

cin >> card_value3;

cout << endl << endl;

}

else if (number_of_cards == 4)

{

cout << "Please input the value of the first card: " << endl;

cin >> card_value1;

cout << "Please input the value of the second card: " << endl;

cin >> card_value2;

cout << "Please input the value of the third card: " << endl;

cin >> card_value3;

cout << "Please input the value of the fourth card: " << endl;

cin >> card_value4;

cout << endl << endl;

}

else if (number_of_cards == 5)

{

cout << "Please input the value of the first card: " << endl;

cin >> card_value1;

cout << "Please input the value of the second card: " << endl;

cin >> card_value2;

cout << "Please input the value of the third card: " << endl;

cin >> card_value3;

cout << "Please input the value of the fourth card: " << endl;

cin >> card_value4;

cout << "Please input the value of the fifth card: " << endl;

cin >> card_value5;

cout << endl << endl;

}

}

int calculate_hand (int& number_of_cards, char& card_value1, char& card_value2, char& card_value3, char& card_value4, char& card_value5)

{

}

You might be interested in
Which statement best describes the types of products and services that are suitable for online sale?
garri49 [273]

A statement which best describes the types of products and services that are suitable for online sale is: D. Not all products or services are well-suited for sale on the Internet.

<h3>What is e-commerce?</h3>

E-commerce is also referred to as an online sale and it can be defined as a business model which is designed and developed to involve the buying and selling of goods (products) over the Internet.

Basically, e-commerce technologies are designed and developed to comprises software and information technology (IT) systems which typically support safe and secure transactions over network and the Internet, so as to make e-commerce possible.

<h3>What is a product?</h3>

A product can be defined as any physical object (tangible item) that is typically produced by a manufacturer so as to satisfy and meet the demands, needs or wants of every customer. Some examples of a product include the following:

  • Mobile phones
  • Television
  • Microwave oven
  • Laptop

In conclusion, we can infer and logically deduce that it is not all products or services that are well-suited for sale on the Internet through e-commerce.

Read more on e-commerce here: brainly.com/question/23369154

#SPJ1

4 0
2 years ago
What is the TSA motto
yulyashka [42]

Answer:

the answer is "Learning to lead in a technical word".

Explanation:

7 0
2 years ago
what is internet ?? mention five ways one can use the internet profitably. state five disadvantages of the internet.​
rosijanka [135]

The Internet can be best described as network of networks since it connects over 50 million computer worldwide.

3 0
3 years ago
what allows separate systems to communicate directly with each other, eliminating the need for manual entry into multiple system
Karolina [17]
Connections, allow separate systems to communicate directly with each other, eliminating the need for manual entry into multiple systems. They do not entirely eliminate information redundancy, but they do ensure information consistency among multiple systems.
6 0
2 years ago
Open the site in your browser. (If any pop-up windows appear, think about what they indicate about the web site before you close
kati45 [8]

Answer:

The answer to the given question is 5-6 (trustworthy).

Explanation:

When visits any web site there are several information is given, We click on it shows some pop-up box. it is smaller than the whole windows. for example, If we want to download any free software. So we go on a software site and choose the version for software and click for download. when we click on download there is a pop-up window open to provide the details of the software and has a one-button when we click on the button it downloads the software. If we cancel the pop-up window by click on the cancel /close (X) button it will close the window.

So the pop-up windows are very trustworthy.

5 0
3 years ago
Other questions:
  • What are the disadvantages of a server-based network? -lack of centralized network security - need for a network administrator -
    14·1 answer
  • Which of the following is *not* true about logging user and program actions on a computer?
    10·1 answer
  • Special effects are added using the _____.
    16·1 answer
  • What does aperture control? A)amount of light the image sensor captures when taking a photo. B)how sensitive the camera is to in
    10·2 answers
  • A browser allows you to set preferences for using the browser. These preferences include all of the following except
    7·1 answer
  • Write a for loop that runs 5 times and accepts the input of an integer number every time. Those numbers will be accumulated by a
    7·1 answer
  • Why do software developers prefer to use high-level language to author programs?
    8·1 answer
  • What is the most important job of a web server?
    11·2 answers
  • What is the most appropriate data type for each of these items?
    15·1 answer
  • Modern life is not possible if computer stops working? Give your opinion<br>​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!