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
What is the purpose of the Subtotal feature?
Svetradugi [14.3K]

Answer:

performs calculations

Explanation:

The SUBTOTAL function in Excel allows users to create groups and then perform various other Excel functions such as SUM, COUNT, AVERAGE, PRODUCT, MAX, etc. Thus, the SUBTOTAL function in Excel helps in analyzing the data provided.

5 0
2 years ago
An Excel formula always begins with a(n) ____.
Basile [38]
Every Excel formula begins with '=' (equality) sign.
7 0
3 years ago
Design an algorithm to generate the sequence of positive integers (In increasing order) whose only prime divisors are 2 and 3.
Natasha2012 [34]

Answer:

es muy buena pero es muy difícil que ni yo pude entender

8 0
3 years ago
List and explain the factors to consider when buying a computer
PSYCHO15rus [73]

Answer:

what it's main use is going to be

Explanation:

The main factor when considering buying a PC is what it's main use is going to be. This will determine what components you will need to look for. For example, if you are going to use the computer for video editing and work then you will need one with a high end CPU and lots of RAM. If you are going to use the PC for regular everyday use such as work programs (AutoCAD, Office, Photoshop, etc. ) Then you can buy a regular office computer with a mid-tier CPU, and 8GB of RAM, and no graphic card. A PC for gaming at high resolutions will require all high end parts including a high end graphics card. Therefore, knowing what its main use will be will determine cost, and what tier components you will need to buy.

3 0
3 years ago
Hi I need help, This assignment is for Assignment 6 Question 4 in edhesive for computer science. here is the prompt:
Alex17521 [72]

Answer:

Following are the python code to print the given pattern:

print('FOURTH') # using print method

for i in range(10): #using loop to count numbers

   for j in range(10-i): # use loop to print asterisk value in reverse order

       print("*", end=" ") #print value

   print("") #using print method for space

Output:

Please find the attachment.

Explanation:

The description of the above python program can be described as follows:

  • In the first line, use the print method, that print message "FOURTH".
  • In the next line, two for loop is used in which the first loop counts the number to be print value, inside the loop another for loop is used.
  • In this loop, it prints asterisk values in its reverse order and for new lines, it will use the print method with a single white space.

7 0
3 years ago
Other questions:
  • Each​ _____ in a relational database table is a unique record of something that users want to track.
    14·1 answer
  • A camera in manual mode means of the camera will make all the adjustments for the photographer
    8·1 answer
  • 20 points fun challenge!!! Can u solve this challenge? Find the only spelled out word in this jumble of letters, there is only o
    6·2 answers
  • You use this method to determine the number of items stored in an arraylist object.
    12·1 answer
  • Which form of Internet access currently uses a technology called 4G?
    15·2 answers
  • -How long does a copyright last?
    6·1 answer
  • Write a JAVA program containing a method called hasEight(), which takes an int as input and returns true if the number contains
    14·1 answer
  • HELLO. Which of the following is NOT a way to control the flow of a program?
    6·2 answers
  • WILL GIVE A BRAINLIEST!!! PLS HELP!!!
    5·1 answer
  • In computing, what does LAN stand for?​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!