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 of the following is a principle that can improve the efficiency of I/O?
natulia [17]

Answer:

C)

Explanation:

One principle that can improve the efficiency of I/O would be to move processing primitives into hardware. Primitives are a semantic value representing something else such as words or numbers within the programming language. By moving them into hardware they system is able to read them at a much faster speed making the I/O more efficient.

5 0
2 years ago
Read 2 more answers
1. What are the advantages and disadvantages of the digital darkroom as compared to a regular
ki77a [65]

Answer:

The advantages of a digital darkroom is that it allows the photographer to make minor changes to improve a photograph. The disadvantage is that the more you want your picture to come out better you would need to waste your time or be patient to get the picture and buy a better camera.

4 0
3 years ago
___ allow users to select controls by keyboard shortcuts. (Points : 3) Alternative keys
PtichkaEL [24]

Answer: Alternative key

Explanation:

 The alternative key is the type of shortcut key in the keyboard that allow the users for selecting the control or shift key. It is also considered as the modifier key. For using the alternative key we must ensure that the lock num is ON in the keyboard.

The alternate key is basically provide the various alternative input and the operation. The short name of the alternate key in the keyboard is denoted as "Alt key". The function of the alternative key may vary from one application to another.    

3 0
3 years ago
What must you use to create a multi-line string?
IrinaK [193]

Answer:

A single pair of three consecutive double quotation marks.

Explanation:

In Python, a multi-line string can be created by enclosing it in three double quotation marks. For example:

string = """This is a Python multi-line string

This is used to print string in multiple lines

This uses three consecutive quotation marks"""

print(string)

Output:

This is a Python multi-line string

This is used to print string in multiple lines

This uses three consecutive quotation marks

In addition to using three double quotation marks, \n and brackets ( ) are also used to create multi-line string in Python.

7 0
3 years ago
Seeing her Daughter graduate from college is most likely a short term goal for a person of which of these ages ? A) 24 years old
scoray [572]
C because you can’t graduate at 4 or 14 and if your kid is graduating when you’re 24 then that means you have birth at 7 years old which isn’t possible.
4 0
2 years ago
Other questions:
  • Determine if the situation below is a safe practice: Julia needs to hang some industrial shelvinv, so she carefully selects the
    9·2 answers
  • Create a cell array, called A, with the following contents: a. Make a copy of A called B. (Nothing complicated: B = A is suffici
    10·1 answer
  • Look at the following form. Which input method is the form using to receive the user's favorite activity? What is your favorite
    12·2 answers
  • When _______ wordart, you need to consider both the font size of the text and the size of the text box that contains wordart?
    15·1 answer
  • Which statement is not true? An audit objective for systems maintenance is to detect unauthorized access to application database
    8·1 answer
  • The __________ is a worldwide collection of networks that links millions of businesses, govenment agencies, educational institut
    14·1 answer
  • What would happen without satellites???
    12·2 answers
  • The process of providing only the essentials and hiding the details is known as _____. a. algorithm b. data structure c. abstrac
    6·1 answer
  • Five uses of the operating system​
    10·2 answers
  • given an array of integers a, your task is to count the number of pairs i and j (where 0 ≤ i &lt; j &lt; a.length), such that a[
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!