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
The Apple II is an IBM-compatible PC "clone.
lutik1710 [3]
Is this supposed to be a true or false question?
4 0
3 years ago
When you add text to a slide using presentation software, which of the following is important?
katrin [286]
I think the answer is B. The text should be brief. 
7 0
4 years ago
Read 2 more answers
Does speedtest report megabytes per second or megabits
Lesechka [4]

that could be both *shrugging*

7 0
3 years ago
Is it safe to tape down cords such as internet cables to the floor?
zhenek [66]

Yes it is safe to tape down cords such as internet cables to the floor

5 0
4 years ago
Give the full form of http​
astraxan [27]
Hypertext Transfer Protocol
h is for hyper
the T in text is the first T
transfer is the second T
and P is for protocol

HTTP hope that helps
8 0
3 years ago
Other questions:
  • Cecelia would like to write an app to help manage a trip to the grocery store. The app will maintain a shopping list (a list of
    7·1 answer
  • Which principle suggests that specific single responsibility interfaces are better than one general purpose interface?
    13·1 answer
  • According to your text, three factors are responsible for the rapid rise in new product development. They are faster and more ec
    9·1 answer
  • Why do you think they added the wait .5 seconds block?
    13·1 answer
  • Spreadsheet software can be used to do all the following except _____.
    5·2 answers
  • What menu and grouping commands is the "SORT" tool? ( please answering meeeee)
    9·1 answer
  • ________ is a human-computer interaction method whereby inputs to and outputs from a computer-based application are in a convent
    8·1 answer
  • What code would you use to create the login button?
    11·1 answer
  • What type of block start a sequence?
    12·1 answer
  • Anil needs to show the overlap of people who live in a certain neighborhood in his city and who support a specific political can
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!