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
According to Porter’s five-forces model, the more the forces combine in any instance, the less likely firms will seek competitiv
Fynjy0 [20]

Answer:

The answer is "Option b"

Explanation:

The five-force model is a simple and powerful way to understand the strength of your enterprise system and recognize your future profitability.  

  • It is beneficial because they know the factors, which affect your environment or your company's profitability.
  • It is a widely available methodology, that defines key factors, which can contribute to a competitive edge, that's why option b is correct.

6 0
4 years ago
What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
drek231 [11]
If you mix white with any color it makes it a lighter shade of that color. For instance mixing white + black = gray, which is a lighter color of black. 

Hope this helps,

kwrob <span />
6 0
4 years ago
Read 2 more answers
In C++ please (read the image below for instructions)
FromTheMoon [43]

Using the knowledge in computational language in C code  it is possible to write a code that  print the month name along with their rainfall inches. Then we have to calculate the total rainfall.

<h3>Writting the code:</h3>

<em>#include <bits/stdc++.h></em>

<em>using </em><em>namespace </em><em>std;</em>

<em />

<em>// function to print the rainfall of each month</em>

<em>void rainfallStatistics(string month[], double rainfall[]){</em>

<em>    </em>

<em>    double sum = 0; // variable to store the total sum of rainfall</em>

<em>    string maxMonth = month[0]; // variable to return month with maximum rainfall</em>

<em>    double </em><em>maxRainfall </em><em>= INT_MIN; // variable to store the maximum rainfall</em>

<em>    </em>

<em>    // running the loop till the last month</em>

<em>    for(int i=0; i<12; i++){</em>

<em>        </em>

<em>        // printing the month and rainfall</em>

<em>        cout<< month[i] << "           " << fixed << setprecision(2) << rainfall[i] << " inches" << endl;</em>

<em>        </em>

<em>        // storing the sum</em>

<em>        sum = sum + rainfall[i];</em>

<em>        </em>

<em>        // checking the month with highest rainfall</em>

<em>        if(rainfall[i] > </em><em>maxRainfall</em><em>){</em>

<em>            </em>

<em>            maxRainfall = rainfall[i];</em>

<em>            maxMonth = month[i];</em>

<em>        }</em>

<em>    }</em>

<em>    </em>

<em>    // calculating the average of the rainfall</em>

<em>    double average = sum / double(12);</em>

<em>    </em>

<em>    cout << endl;</em>

<em>    cout << "Total for the year " << sum << " inches" << endl;</em>

<em>    cout << "Average rainfall per month " << average << " inches" << endl;</em>

<em>    cout << "Month with the greatest rainfall was " << maxMonth << " with rainfall of " << </em><em>maxRainfall </em><em><< " inches" << endl;</em>

<em>    </em>

<em>}</em>

<em>// driver program</em>

<em>int main()</em>

<em>{</em>

<em>    // array to store the nonth name</em>

<em>    string month[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};</em>

<em>    </em>

<em>    // array to store the rainfall</em>

<em>    double rainfall1[12] = { 4.50, 4.25, 3.26, 1.35, 0.80, 0.20, 0.10, 0.00, 0.40, 1.20, 2.96, 4.71 };</em>

<em>    double rainfall2[12] = { 3.50, 1.25, 7.26, 8.35, 2.80, 0.00, 1.10, 4.00, 9.40, 2.20, 3.96, 4.71 };</em>

<em>    </em>

<em>    cout << "Hayward Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Hayward</em>

<em>    </em><em>rainfallStatistics</em><em>(month, rainfall1);</em>

<em>    cout << endl;</em>

<em>    cout << endl;</em>

<em>    </em>

<em>    cout << "Houston Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Houston</em>

<em>    rainfallStatistics(month, rainfall2);</em>

<em>    </em>

<em>    return 0;</em>

<em>}</em>

See more about c code at brainly.com/question/19705654

#SPJ1

8 0
2 years ago
Which of the following is a feature that allows you to temporarily store text? A wordvault, B Clipboard,C Normal View, D typeove
Sati [7]
Notes on an iPhone or Mac.
6 0
4 years ago
A network admin configures a static route on the edge router of a network to assign a gateway of last resort (the router that co
kupik [55]

Answer:

Use the default-information originate command.

Explanation:

A network administrator customizes a fixed path on a channel's edge router for creating any last recourse gateway that is the router connecting to the online / ISP. So, they using the usual command source to customize the edge router to connect this path instantly using RIP.

That's why the following answer is correct according to the scenario.

8 0
3 years ago
Other questions:
  • Which combination of factors would result in the lowest monthly mortgage payment?
    9·2 answers
  • Describe a new career in computer science that may be created in the future. Include supporting evidence in your response that s
    13·1 answer
  • In a stream channel what is deposited first?
    7·1 answer
  • Options to open, save, and print a document are found on which of the following tabs?
    9·2 answers
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • Robert gets home from school at 3 p.M. His mom has to leave for her shift at work at 3:15 and she wants him to watch his baby br
    9·1 answer
  • What are some other features of sending attachments in Outlook 2016? Check all that apply.
    9·2 answers
  • Cómo mi dificar el aspecto del texto​
    12·2 answers
  • CLS
    12·1 answer
  • All of the following are properties of a relation except __________.Group of answer choicesThe order of tuples (rows) is not sig
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!