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
Electronic ledger that tracks mathematical data
lesya692 [45]
<span>These kinds of systems are usually installed in the cockpits of aircrafts. It is an electronic computer-controlled display system. It is made up of several kinds of systems constituting the whole.  The purpose of such a kind of display is to increase and widen the field of vision and decrease any kind of visual disturbances from the surroundings. The Flight Data Display another constituent of the system constantly updates the pilots with the status of and data related to the flight. This also includes information about the aircraft itself and navigation information too.</span>
7 0
3 years ago
what is the name of the program that enables the device and operating system to communicate with each other?
Fittoniya [83]

Answer:

Explain Operating System working: OS works as an intermediate between the user and computer. It helps the user to communicate with the computer without knowing how to speak the computer's language. The kernel is the central component of a computer operating systems.

Explanation:

3 0
2 years ago
When a person visits a web site, his or her ip address and the links he or she clicked on are automatically recorded. this is an
allochka39001 [22]
B. Invisible information gathering.
8 0
3 years ago
This is a device that enables computers to be connected to a network.
zhuklara [117]

The answer to your question is,

NIC - Network Interface Card

-Mabel <3

8 0
3 years ago
Which of the following documents should beprepared before the commencement of a softwareproject?
ludmilkaskok [199]

Answer:

Software requirement specification

Explanation:

requirement specification is the first step before proceeding with any project.

we should validate our output at all phases with software requirement specification

7 0
3 years ago
Other questions:
  • Mention 3 wast water draining system on home​
    7·1 answer
  • Spreadsheet software creates a ____, composed of a grid of columns and rows
    5·1 answer
  • When you compose a message, you want your audience to find the information it needs quickly and to understand what it finds. You
    11·1 answer
  • A user makes a request to implement a patch management service for a company. As part of the requisition the user needs to provi
    7·1 answer
  • Which of the following terms describes surgery through a small incision in the abdomen?
    11·1 answer
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • Which software programs should students avoid using to create and submit course work? (Choose all that apply). Word, Pages, Numb
    13·1 answer
  • What can you use to make sure that you have no errors in Word Online?
    5·1 answer
  • Can anyone help my please
    10·2 answers
  • How is distributed ledger technology (DLT) used in a blockchain?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!