Question

Write a program that calls the random number generator two times to simulate rolling a pair...

Write a program that calls the random number generator two times to simulate rolling a pair of dice. It should store the two numbers into variables. It will then determine if the dice roll is a winner (doubles OR add up to 7). Remember to add two includes and also to seed the random number generator to the clock.

This will roll two dice and add them together.

Doubles, or a total of 7 - YOU ARE A WINNER!!!

First dice: 4

Second dice: 2

BETTER LUCK NEXT TIME

Sample output 2 is given below.

This will roll two dice and add them together.

Doubles, or a total of 7 - YOU ARE A WINNER!!!

First dice: 1

Second dice: 1

YOU WON!!!!

Sample output 3 is given below.

This will roll two dice and add them together.

Doubles, or a total of 7 - YOU ARE A WINNER!!!

First dice: 4

Second dice: 3

YOU WON!!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As per HomeworkLib expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as per HomeworkLib guidelines.
******************************************************************************************

#include <bits/stdc++.h>

#include <time.h>

using namespace std;

int main() {

srand(time(NULL));

cout<<"This will roll two dice and add them together.\nDoubles, or a total of 7 - YOU ARE A WINNER!!!\n";

cout<<"First dice:";

int first = rand()%6 +1;

cout<<first<<endl;

cout<<"Second dice:";

int second= rand()%6 +1;

cout<<second<<endl;

if((first==second)||((second+first)==7))cout<<"YOU WON!!!!\n";

else cout<<"BETTER LUCK NEXT TIME\n";

  return 0;

}

Add a comment
Know the answer?
Add Answer to:
Write a program that calls the random number generator two times to simulate rolling a pair...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ( Java Programming ) Write an application to simulate the rolling of two dice. The application...

    ( Java Programming ) Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12...

  • Write a C PROGRAM that will simulate rolling a die. When rolling a die, one will...

    Write a C PROGRAM that will simulate rolling a die. When rolling a die, one will get a die face value of 1-6. We can use rand function and math ceiling function to get a random number of 1-6 generated. The program will simulating rolling 5 dice simultaneously and store their face values into an array of size 5. The program will keep rolling the dice and print the following: 1. All face values in one line 2. If any...

  • Linear Congruence Generator Below is a generator desigred to simulate rolling a six sided de (d6)....

    Linear Congruence Generator Below is a generator desigred to simulate rolling a six sided de (d6). Note: the +1 is to adjust the outcome so you can get a roll of 6 and and do not get o roll of roll, = [(13. rollm-L 4)mod 6 11 5. Using the formula above, determine the outcome of the first 10 rolls in the sequence if the first roll is 3 Roll Number Die Result 6. Come up with a recurrence relation...

  • Simulate rolling two, fair, six-sided dice 10000 times and adding the "up" faces together each time...

    Simulate rolling two, fair, six-sided dice 10000 times and adding the "up" faces together each time using the "Dice Generator." Plot a relative frequency histogram of the results. Please note that your data will be randomly generated; therefore, select the answer below that is most similar to the histogram that you generated from your random data. If this is challenging, consider all four simulation questions in this assignment at the same time and look for the expected pattern in the...

  • Please i need helpe with this JAVA code. Write a Java program simulates the dice game...

    Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...

  • How to write python code that is a dice rolling function that generates random numbers. The...

    How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...

  • Write a program to simulate rolling three dices simultaneously. Keep rolling these three dices until the...

    Write a program to simulate rolling three dices simultaneously. Keep rolling these three dices until the three dices show the values of “1”, “2”, and “3” (we call this condition 1. The dices are in no particular orders to show these values in this case). Then the program shows the values of the three dices and the number of rolling so far. After that the rolling continues (and counting of the number of rolling continues too) until the first dice...

  • Write a java program that simulates the rolling of four dice. The program should use random...

    Write a java program that simulates the rolling of four dice. The program should use random number generator to roll dice. The sum of the four values should then be calculated. Note that each die can show an integer value from 1 to 6, so the sum of the four values will vary from 4 to 24, with 14 being the most frequent sum and 4 and 24 being the least frequent sums. Your program should roll the dice 12,960...

  • (MATLAB) Write a program that simulates a dice roll by picking a random number from 1-6...

    (MATLAB) Write a program that simulates a dice roll by picking a random number from 1-6 and then picking a second random number from 1-6.    How many times do you get two 1’s. What many times do you get two 1’s if you simulate 10,000 rolls of a pair of dice?

  • PYTHON: Dice Rolling Write a script that takes input for the number of dice to roll...

    PYTHON: Dice Rolling Write a script that takes input for the number of dice to roll and for the number of sides for the dice. Roll that many n-sided dice and store the values an array. Take the number of sides of the dice and the number of dice as typed inputs from the user. Output should be a comma separated list of the die numbers with no spaces like this: 6,4,1,3,1 Write a script that will simulate the roll...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT