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
What is the main difference between a literacy society and a digital Society
EleoNora [17]
The accurate answer is

The difference is a Literacy Society is a program for encouraging people to read.
A Digital Society is a program that as to do with technology at work,school, or at home.

Glad to help :) 
7 0
3 years ago
What are the differences between a trap (aka software interrupt) and an interrupt (hardware interrupt)? What is the use of each
Marta_Voda [28]

Answer:

Trap is a software interrupt that occurs when there is a system call, while hardware interrupt occurs when a hardware component needs urgent attention.

Explanation:

Interrupt is an input signal that disrupt the activities of a computer system, giving immediate attention to a hardware or software request.

In trap interrupt, the system activities are stop for a routine kernel mode operation, since it has a higher priority than the user mode. At the end of the interrupt, it switches control to the user mode.

The hardware interrupt is a signal from hardware devices like the input/output devices, storage and even peripheral devices that draws an immediate attention of the processor, stopping and saving other activities and executing the event with an interrupt handler.

6 0
3 years ago
Computer science practical on VB.NET. program 1. program to find the square of a number. write the code achieve it​
Korvikt [17]

Answer:

Module Program

   Sub Main()

       Dim num As Integer

       num = 4

       Console.WriteLine("The square of " & num & " is " & num * num)

       Console.ReadKey()

   End Sub

End Module

Explanation:

Very similar to the other program you posted.

6 0
2 years ago
The three basic processes of memory are ______.
marysya [2.9K]

Answer:

The correct answer is letter "C": encoding, storage, retrieval.

Explanation:

In psychology, the stages of memory are <em>encoding, storage, </em>and <em>retrieval</em>. Encoding refers to changing the information as it is received so it can be stored in the memory and imply inputs in three kinds: <em>visual (pictures), acoustic (sounds), </em>and<em> semantic (meaning)</em>. Storage is the stage in which the input is retained in the memory, where it is stored, and for how long. Finally, retrieval implies organizing information stored in the memory to recall it.

6 0
2 years ago
Which keyboard feature is a form feed character?
Sever21 [200]

Answer:

B

Explanation:

The form feed character code is defined as 12 (0xC inbhexademical), and may be represented as control+L or^L. In a related use, control+L can be used to clear the screen in Unix shells such as bash. In the C programming language ( and other languages derived from C ), the form feed character is represented as '\f'.

5 0
2 years ago
Other questions:
  • All animations on the world wide web are flash animations
    11·2 answers
  • For an external usb hard drive attached to a computer, which is more suitable: a writethrough cache or a block cache
    14·2 answers
  • What kind of security features does Microsoft Security Analyzer promise?
    5·1 answer
  • What is the name of the amount of space between the content of a document and the edge of the page
    13·1 answer
  • Suppose that f() is a function with a prototype like this: void f(________ head_ptr); // Precondition: head_ptr is a head pointe
    15·1 answer
  • The system partition is the partition that contains the files required to load the operating system (bootmgr, and BCD). The syst
    9·1 answer
  • You might have trouble interpreting a message if:
    15·1 answer
  • Write a function named findmax()that finds and displays the maximum values in a two dimensional array of integers. The array sho
    13·1 answer
  • What is the velocity of a 0.100kg car with a momentum of 5 kgm/s?
    12·1 answer
  • Which feature of cryptography is used to prove a user's identity and prevent an individual from fraudulently reneging on an acti
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!