0

Write a program that rolls a dice (but hide the number from player) and then ask user enter a number in range of 1 - 6. If player enters same number of computer rolled, then the player earns $10. If player enters a number that is smaller or larger by 1, then the player earns $3. If player enters a number that is smaller or larger by 2, then the player earns $1. Player has to pay $3 dollar to play once. Make a MatchDice game.

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by stultuske
0

int die1;
int die2;
int roll;

die1 = (int)(Math.random()*6) + 1;
die2 = (int)(Math.random()*6) + 1;
roll = die1 + die2;

0

how can i let the computer choose ?

What is the computer supposed to choose?
If you want a random choice, use the Random class (or Math class's random()) to generate random numbers.

0

how can i write it in the Eclipse

well ... typing your code in eclipse, rather than in a post here would be a good start.
I don't really see anything wrong with your code above, so what exactly is it what you need help with?

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.