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
Naddika [18.5K]
3 years ago
10

Use C++

Computers and Technology
1 answer:
galina1969 [7]3 years ago
7 0

Here you go. Let me know if you need clarifications.

#include <iostream>

using namespace std;

int main()

{

bool play = true;

while (play)

{

 // Game starts

 int card1 = rand() % 10 + 1;

 int card2 = rand() % 10 + 1;

 cout << "First cards: " << card1 << ", " << card2 << endl;

 int total = card1 + card2;

 cout << "Total: " << total << endl;

 bool answergiven = false;

 bool gamefinished = false;

 char answer;

 // Game loop

 while (!gamefinished)

 {    

  answergiven = false;

  while (!answergiven)

  {

   cout << "Do you want another card? (y/n): ";

   cin >> answer;

   answergiven = (answer == 'y') || (answer == 'n');

  }

  if (answer == 'y')

  {

   int card = rand() % 10 + 1;

   cout << "Card: " << card << endl;

   total += card;

   cout << "Total: " << total << endl;

   if (total > 21)  

   {

    cout << "Bust." << endl;

    gamefinished = true;

   }  

   else if (total == 21)

   {

    cout << "Congratulations!" << endl;

    gamefinished = true;

   }

  }

  else  

  {

   gamefinished = true;

  }

 }

 // Game ends

 answergiven = false;

 while (!answergiven)

 {

  cout << "Would you like to play again? (y/n): ";    

  cin >> answer;

  answergiven = (answer == 'y') || (answer == 'n');    

 }

 play = (answer == 'y');

}

}

You might be interested in
Please help! i need to answer this soon!
natali 33 [55]

Answer:

1. a modem connects a computer to the internet  

4. a modem transmits digital signals over a telephone line

5. a dial-up modem communicates using a telephonic call​

All of three mentioned above.

Modem stands for modulator de-modulator, and it connects the computer to the internet. Its not the fastest, which is router. And the connection is established via the telephone line, through which the digital signals is being transmitted, And the type used is dial up communication.

Explanation:

The answer is self explanatory.

4 0
4 years ago
A(n) _____ chart is drawn on the same worksheet as the data.
Harrizon [31]
The answer is An embedded chart
6 0
4 years ago
What are the six command groups in powerpoint
DiKsa [7]

Answer:

Clipboard, Slides, Font, Paragraph, Drawing, and Editing

3 0
3 years ago
A computer program that translates a program statement by statement into machine language is called a/an?
PtichkaEL [24]
Executor. IT executes the program.
6 0
4 years ago
. Service recovery refers to A. the ability to quickly restore service following a service failure and provide compensation. B.
san4es73 [151]

Answer:

A. the ability to quickly restore service following a service failure and provide compensation.

Explanation:

Systems like servers are bound to fail at some point. This is because, it either has running parts or electronic components that could overheat or get shorted due to external or internal malfunction.

The ability of system to quickly restore services and operation after it experiences a total system failure is called system recovery.

7 0
3 years ago
Other questions:
  • In three or four sentences, describe how a person buys and sells stock.
    6·2 answers
  • Categories of functions specified by computer instruction?
    11·1 answer
  • The four functions of a computer are
    5·1 answer
  • If your vehicle catches fire while you are driving, you should:
    5·2 answers
  • Someone please help me with the right answer please
    12·1 answer
  • Can someone help me with this
    10·1 answer
  • What are 5 good movies like The Breakfast Club or 8 Mile?
    14·2 answers
  • Will social media lose its relevance?​
    6·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
  • An animation of a person standing with their arms extended out to their sides. There are 3 dimensional boxes around the torso of
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!