Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


help with a simple java problem

ApplellialApplellial Member Posts: 21
Hello, so, as the title says, I could use some help with a simple problem I've run into when trying to code a little game, to try and refresh my java skills (which clearly are lacking severely >.< ).

So, I made a game and I want to have the players take turns. I've decided to try and challenge myself and make the turns be decided on who can guess nearest to a random number from 0-100.

I have the random number generator and the user inputs, but I'm running into trouble figuring out how to find out who got nearest to the generated number.

I have the two variables, p1_guess and p2_guess, right now and the random number generator.

If anyone can offer any help or advice on this it would be most appreciated, and don't worry, it's not a homework assignment; I'm a sad person and do this for "fun"... XD

Thank you,


  • j2me64j2me64 Member Posts: 20

    hello, you can substract the p1_guess from the random number and the same for p2_guess and the smaller result is nearer.
Sign In or Register to comment.