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
aliina [53]
2 years ago
5

Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll

as many times as you like (if you don't like your 2 dice), while the computer only rolls once, after you have decided that you like your two dice. Determine who wins, you or the computer. g
Computers and Technology
1 answer:
charle [14.2K]2 years ago
6 0

Answer:

#include <iostream>

#include <time.h>

#include <string>

using namespace std;

int main(){

srand(time(NULL));

cout<<"Throw dice"<<endl;

int b =0;

int a=0;

a=rand()%6;

b=rand()%6;

for (int i =0;i<1;i++)

{cout<<"dice one: "<<a<<endl;}

for (int i =0;i<1;i++)

{cout<<"dice two: "<<b<<endl;}

if(a>b)

{cout<<"first dice won"<<endl;}

if(b>a)

{cout<<"second dice won"<<endl;}

else{cout<<"they are same"<<endl;

return main();

}

return 0;

}

Explanation:

/*maybe it help you it is almost done*/

You might be interested in
Leah deals with several file conversions every day.
Lelechka [254]
That’s not a question but good for her
5 0
3 years ago
Which page feature is used in long documents to assist readers in quickly finding information in the document without having to
irakobra [83]

Maybe it is Ctrl-F... is this what you're thinking of?

3 0
3 years ago
Read 2 more answers
Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B tr
drek231 [11]

Answer:

Here is the C++ program:

#include <iostream>  // to use input output functions

#include <cmath>  // to use math functions like sqrt()

#include <iomanip>  //to use setprecision method

using namespace std;   //to access objects like cin cout

int main ()  {  //start of main function

  double speedA;  //double type variable to store average speed of car A

  double speedB;  //double type variable to store average speed of car B

  int hour;  //int type variable to hold hour part of elapsed time

  int minutes;  //int type variable to hold minutes part of elapsed time

  double shortDistance;  // double type variable to store the result of shortest distance between car A and B

  double distanceA;  //stores the distance of carA

  double distanceB;  //stores the distance of carB

  double mins,hours;   //used to convert the elapsed time

cout << "Enter average speed of car A: " << endl;  //prompt user to enter the average speed of car A

cin >> speedA;   //reads the input value of average speed of car A from user

cout << "Enter average speed of car B: " << endl ;  //prompt user to enter the average speed of car B

cin >> speedB;   //reads the input value of average speed of car A from user

cout << "Enter elapsed time (in hours and minutes, separated by a space): " << endl;  //prompts user to enter elapsed time

cin>> hour >> minutes;    //reads elapsed time in hours and minutes

  mins = hour * 60;  //computes the minutes using value of hour

  hours = (minutes+mins)/60;     //computes hours using minutes and mins

distanceA = speedA * (hours);  // computes distance of car A

distanceB = speedB * (hours);   //computes distance of car B

   shortDistance =sqrt((distanceA * distanceA) + (distanceB * distanceB));   //computes shortest distance using formula √[(distanceA)² + (distanceB)²)]

cout << "The (shortest) distance between the cars is: "<<fixed<<setprecision(2)<<shortDistance;

//display the resultant value of shortDistance up to 2 decimal places

Explanation:

I will explain the program with an examples:

Let us suppose that the average speeds of cars are:

speedA = 70

speedB = 55

Elapsed time in hours and minutes:

hour = 2

minutes = 30

After taking these input values the program control moves to the statement:

mins = hour * 60;  

This becomes

mins = 2 * 60

mins = 120

Next

hours = (minutes+mins)/60;

hours = (30 + 120) / 60

         = 150/60

hours = 2.5

Now the next two statements compute distance of the cars:

distanceA = speedA * (hours);  

this becomes

distanceA = 70 * (2.5)

distanceA = 175

distanceB = speedB * (hours);

distanceB = 55 * (2.5)

distanceB = 137.5

Next the shortest distance between car A and car B is computed:

shortDistance = sqrt((distanceA * distanceA) + (distanceB * distanceB));

shortDistance = sqrt((175 * 175) + (137.5 * 137.5))

                        = sqrt(30625 + 18906.25)

                        = sqrt(49531.25)

                        =  222.556173

shortDistance =  222.56

 

Hence the output is:

The (shortest) distance between the cars is: 222.56        

3 0
3 years ago
Which site had a major influence on the social gaming site Friendster?
Oduvanchick [21]
The answer is, "Ryze".
4 0
3 years ago
Read 2 more answers
Mi laptop dice the computer restarted unexpectedly or encountered an unexpected error.Windows installation cannot procced.To ins
borishaifa [10]

Answer:

Explanation:

There are two reasons as to what could have happened with your laptop. The first one is that your laptop was installing a critical windows update which got corrupted when the laptop's battery died causing windows itself to become corrupted. In this case, you would need to format the hard drive and reinstall windows. The second reason could be that your hard drive is failing and not allowing Windows to load or properly be installed on it. In this second scenario you would need to buy and replace the hard drive.

4 0
3 years ago
Other questions:
  • Nick is a food blogger. He first writes his draft on an electronic document, checks and corrects mistakes, and pastes the conten
    9·2 answers
  • If a storm is 7.5 kilometers away, how much time is expected between observations of lightning and thunder? Round your answer to
    10·1 answer
  • Who would be a member of the American Dental Association?
    10·1 answer
  • Software on your computer is taking a long time to load. What could help solve this problem?
    5·1 answer
  • Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat
    11·1 answer
  • Suppose Client A initiates a Telnet session with Server S. At about the same time, Client B also initiates a Telnet session with
    13·1 answer
  • A data center needs to ensure that data is not lost at the system level in the event of a blackout. Servers must stay operable f
    6·1 answer
  • Que significa el término “Informática”?
    11·1 answer
  • Fun with Characters
    7·1 answer
  • In the 1760s and early 1770s, the British government wanted to raise money by taxing the residents of its colonies in North Amer
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!