Results 1 to 4 of 4
- 07-21-2008, 03:30 AM #1
Member
- Join Date
- Jul 2008
- Posts
- 21
- Rep Power
- 0
Help with dice game...student seeking advice
Hi, im new here. taking a beginner class in java. this second program is giving me a time...
the rules of the program are in the text attachment. Im having trouble figuring out what i need in a loop. and if i need nested loops.
Also can i nest a for loop inside a do while loop.
This one is giving me a hard time guys, please help....
also yes this is a homework problem, not trying to get someone to give me the answer or do it for me, just need some direction on this one....
thanks,
Allan
- 07-21-2008, 04:05 AM #2
Yes you can nest one type of loop within another.
Give the program a start. If you don't know what to code at a particular point, write some comments on what you'd like to do there. For example:
// Here I roll a die and get a random value from 1 to 6.
or
// Get the number of games to be played
Layout the structure of the game, post it with your questions and someone will help.
- 07-21-2008, 05:03 AM #3
Member
- Join Date
- Jul 2008
- Posts
- 21
- Rep Power
- 0
while (userGuess != sum)
{
for (countRolls = 1; countRolls <=3; countRolls++)
{
//create a Random class object.
Random randomNumbers = new Random();
//Get two random numbers.
dice1 = randomNumbers.nextInt(6);
dice2 = randomNumbers.nextInt(6);
//Sum the two die numbers
sum = (dice1 + dice2)
//output the number of each die with asteriks
System.out.println("Die 1 Die 2");
System.out.println("-----------------");
ok, i believe i have the most of it. One thing thats getting me is how to output a picture of the asteriks for whatever random number is generated for each die. I know im gonna have to do an if/else statement for this..
any help on how to do this would greatly be appreciated....Last edited by waparson; 07-21-2008 at 05:07 AM.
- 07-21-2008, 03:31 PM #4
Similar Threads
-
Roll 2-Dice "Pig" Game Help
By King8654 in forum AWT / SwingReplies: 7Last Post: 04-07-2008, 06:58 PM -
Student Help
By mattwaab in forum Java AppletsReplies: 0Last Post: 02-08-2008, 05:31 PM -
please help a student
By jvasilj1 in forum New To JavaReplies: 0Last Post: 02-01-2008, 01:11 AM -
Help debugging a dice game
By Windoze in forum New To JavaReplies: 7Last Post: 11-22-2007, 01:01 AM -
help debugging a dice game
By Windoze in forum Advanced JavaReplies: 0Last Post: 11-16-2007, 10:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks