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
Search engines use indexes created by web _________ to provide fast searches.
Nastasia [14]
Search engines use indexes created by web crawlers to provide fast searches.
3 0
3 years ago
Who is the CEO of Quora?
irina [24]
Adam D'Angelo is the CEO and co-founder of Quora, an online knowledge market. He was also chief technology officer and <span>vice president of engineering for Facebook.</span>
5 0
2 years ago
While reading difficult content, you should always start witha.Surveying the chapterc.Reading the chapterb.Defining vocabulary w
katrin [286]
When reading difficult content you should- Survey the chapter.

Surveying the chapter allows you to better interpret the literary text and therefore be able to answer the following questions or summarize. 

Hope I helped,
-CSX :)
5 0
3 years ago
This is a wise and hard question.....What is the hardest question in the world? I know the answer do you?
SpyIntel [72]
Is it this question? I think the hardest question in the world is the one you just asked! Am I right?
8 0
3 years ago
Fundamental of Computer Science
Anastaziya [24]

Answer:

Coding and Hardware Hacking

Explanation:

You can learn coding just as well through a online class or even on the internet through yo*tube than an in person class whereas it would be alot easier learning hardware hacking in person because you are given the opportunity to ask and can be corrected for small mistakes due to the task being manual. Coding can be learnt online independently if needed although so can hardware hacking but having a teacher to correct you and teach you handy tricks from their experience will get you further in that sense.

3 0
2 years ago
Other questions:
  • Jason is creating a webpage on the basic parts of a camera. He has to use a mix of both images and content for the web page to h
    11·1 answer
  • You can put a small level on your camera to help keep the horizons straight? TRUE OR FALSE
    14·2 answers
  • You have just finished writing a lengthy research paper and you are ready for formatting. You insert your paragraph headings and
    15·1 answer
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    11·1 answer
  • In addition to ranking the relevance of a particular site according to the keywords entered by the user, which of the following
    10·1 answer
  • How to change color of object in photoshop?
    10·2 answers
  • Why must you be careful when handling a hard drive?
    10·1 answer
  • Cite an early photographic pioneer or invention. Explain their/its impact on photography as we know it today.
    14·1 answer
  • In Outlook 2016, the Tell Me function can be accessed by
    15·2 answers
  • ________ is the general name for a security flaw in a program. Group of answer choices A security fault A virus Malware A vulner
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!