I need help writing a dice game code

Rules of the Game:1- Randomly roll the first dice once(six-sided dice).
2- Randomly roll the second dice.
3-Compare first and second dice.
a. If they are equal in less than 3 rounds, announce that you got a match and that computer won.
b. If they are not equal in less than 3 rounds, keep checking for a match and then announce that you got a match in “X” rounds and that the computer lost this turn.
c. Note: The first dice only roll randomly once and with each round, the second dice will roll randomly until you get a match.
4- After you announce either the computer won or lost, you will ask the user if they want to have another turn.
a. If the user wanted to have another turn, then you will repeat all previous steps.
b. If the user decided to end the game, then output a message to the user “Have a great day” and terminate the program.


I don't know where to start my program.
just do little pieces.
start with the random / #1 and 2 are the same, just save the result of *something* into two variables.
consider <random>
the example here, line 16 gets a number from 0-9. that is the line you want to have as a 'roll' along with some setup found above it -- lines 10 and 11.
https://www.cplusplus.com/reference/random/uniform_int_distribution/

everything else in your program is likely things you have done before, if you have done an 'if' statement and maybe a loop? Try adding just a little at a time, then test it and get that small bit working.
Last edited on
zimhoff wrote:
I don't know where to start my program.

With item 1.
How far have you got in learning C++? What don't you understand? What c++ are you having trouble with?
Topic archived. No new replies allowed.