Hello forum,

I want to write a simple code of two dices rolling for two players. The players can roll as many times as they want per turn. If they are matching numbers, the total is zero. If a person passes, it is passed on to the next player. Please reply for clarification. Currently i have this.

int1=(int) (Math.random()*6) +1;
int2=(int) (Math.random()*6) +1;

A player should be able to pass and the points collected will be added to their total. First to get to 100 win! Thank you

Edited by writeout: n/a

6 Years
Discussion Span
Last Post by CSloan7597

You're going to have to show more effort than that if you expect any help.

Ask specific questions about the parts you are struggling with.


ok so i have

con.println (dice1 and dice2 which gives me the total)

i need help on having two player turns and if the player says pass, the total is added. Once a player's total has reached 100 the game stops.

int1=(int) (Math.random()*6) +1;
int2=(int) (Math.random()*6) +1;

if (int1==int2){
con.println ("Your total is now zero");

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code


You really should at least attempt to come up with a solution yourself, this is a help forum, not a do my work for me forum.

You clearly have some programming knowledge, so think about it as a problem solving exercise, its simple enough, then implement it with programming.


yes i have some code but the problem is to loop the cycle and implement a point system for both players


Exactly. Problem is to "loop" the cycle, you know this, yet I see no loops in your code, you could easily do that yourself.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.