This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
Dice Doubles - How do I get the two random numbers to re-randomize?
Post Body
This is my code:
import java.util.Scanner;
import java.util.Random;
public class Dice{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int firstroll, secondroll;
firstroll = r.nextInt(6);
secondroll = r.nextInt(6);
while(firstroll != secondroll){
System.out.println("DICE!");
System.out.println("First roll: " firstroll);
System.out.println("Second roll: " secondroll);
System.out.println("Your total: " (firstroll secondroll));
}
}
}
I don't even really understand what I'm doing wrong - should I not be saving the r.nextInt(6)'s into variables? I've already tried moving firstroll and secondroll into the whileloop, and still having them initialize outside of the loop, but it still doesn't work. Any advice here?
Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
24,702
Link Karma
6,007
Comment Karma
18,662
Profile updated: 6 days ago
Posts updated: 9 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 11 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/programming...