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
musickatia [10]
3 years ago
10

21. Dice Game Write a program that plays a simple dice game between the computer and the user. When the program runs, a loop sho

uld repeat 10 times. Each iteration of the loop should do the following: • Generate a random integer in the range of 1 through 6. This is the value of the computer’s die. • Generate another random integer in the range of 1 through 6. This is the value of the user’s die. • The die with the highest value wins. (In case of a tie, there is no winner for that particular roll of the dice.) As the loop iterates, the program should keep count of the number of times the computer wins, and the number of times that the user wins. After the loop performs all of its iterations, the program should display who was the grand winner, the computer or the user.
Computers and Technology
1 answer:
Brrunno [24]3 years ago
5 0

Answer:

See Explanation Below

Explanation:

// Program is written in C++ programming language

//.. Comments are used for explanatory purposes

// Program starts here

#include<iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

int main()

{

int computerWins = 0, computerPlay = 0;

int userWins = 0, userPlay = 0;

int tiedGames = 0;

// Computer Play

for (int play = 0; play< 10; play++) {

   computerPlay = rolls();

   userPlay = rolls();  

   // Check who wins

//Clear Screen

System("CLS")

   if (computerPlay == userPlay) {

       tiedGames++;

cout<<"Ties........" + tiedGames;    }

else {

       if (computerPlay> userPlay) {

           computerWins++;

cout<<"Computer...."<< computerWins;

       } else {

           userWins++;

cout<<"User........"<< userWins;

      }

  }

}

return 0;

}

int rolls() {

srand((unsigned)time(0));

return rand() % 6 + 1;

}

You might be interested in
Urgent. I will mark you brainliest. explain why cyber warfare is a real threat.​
stellarik [79]

Answer: Cyber warfare is a real threat since being able to hack another computer especially a countries computer with lots of info in their weaknesses can lead to their downfall. Since they can even possibly if their skilled enough hack their entire data base system and leak it to the public and that wouldn't be good for them not in a single possible way. That's the reason it's dangerous not only that but also because they can access their servers; which can let them access anything online from the whole country including banking information military info which can let them know which area there gonna go to next equipment there gonna bring and where they're gonna launch missiles, bombs, even nukes if they decide to launch one. And being able to hijack the computer that launches the nukes can make the hacker launch the nuke to a different place or launch the nuke on the country trying to launch the nuke.

Explanation:

3 0
3 years ago
Read 2 more answers
Which. Option tilts the image both horizantly and vertically be degrees
Anit [1.1K]
Aaaaaaaeeeeeeeeiiiiiioooooouuuuuu
3 0
3 years ago
Barat explains that if you have a cell that is the sales price of a given product, the value of which will change to produce the
Mice21 [21]

Answer Choices:

a.goal cell

b.constraint

c.changing cell

d.absolute cell

Answer:

c.changing cell

4 0
3 years ago
Debt is a legal obligation to repay what you owe. Which of the following is NOT a debt instrument?
tensa zangetsu [6.8K]
Equity (A.), you always have to pay loans and Morrgages
5 0
3 years ago
What prevents someone who randomly picks up your phone from sending money to themselves using a messenger-based payment?
Gekata [30.6K]

Answer:

Explanation:

There are various safety features in place to prevent such scenarios from happening. For starters phones usually have a pin code, pattern code, or fingerprint scanner which prevents unauthorized individuals from entering into the phone's services. Assuming that these features have been disabled by the phone's owner, payment applications usually require 2FA verification which requires two forms of approval such as email approval and fingerprint scanner in order for any transactions to go through. Therefore, an unauthorized individual would not have access to such features and would not be able to complete any transactions.

6 0
3 years ago
Other questions:
  • What is the best class setup for the mp5 in Modern Warfare?
    7·1 answer
  • Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?
    15·1 answer
  • You have a chart that shows 100 data points and you've circled the highest value. Which of the following are you using?
    9·2 answers
  • The main parts of a lever are the....
    6·2 answers
  • Name the six parts of the product development life cycle.
    7·2 answers
  • In programming, what is a string?
    8·2 answers
  • Primary technology skills are skills that are necessary for success in online education
    9·2 answers
  • Given a line of text as input, output the number of characters excluding spaces, periods, or commas. If the input is:
    12·1 answer
  • A common attack in which a client's cookies, security tokens, or other personal information is obtained and used to impersonate
    7·1 answer
  • This is an example of what type of formula?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!