import java.util.Scanner;
import java.util.Random;
public class DiceRoll {
public static final int SIDES = 6;
public static void main(String[] args) {
// TODO Auto-generated method
stub
System.out.println("Enter the
number of times a 6 sided die should be rolled ");
Scanner keyboard = new
Scanner(System.in);
Random r = new Random();
int times =
keyboard.nextInt();
boolean valid = false;
while(!valid) {
if (times >
0) {
valid = true;
}else {
System.out.println(" Input is invalid and cannot
be less than one ");
times = keyboard.nextInt();
}
}
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six = 0;
int sideCount = 0;
while(sideCount < times) {
int Roll =
r.nextInt(SIDES);
if (Roll == 0)
{
one++;
}else if(Roll ==
1) {
two++;
}else if(Roll ==
2) {
three++;
}else if(Roll ==
3) {
four++;
}else if(Roll ==
4) {
five++;
}else if(Roll ==
5) {
six++;
}
sideCount++;
System.out.println(Roll+1 + " was rolled");
}
System.out.println("One:
"+one+"\nTwo: "+two+"\nThree: "+three+"\nFour: "+four+"\nFive:
"+five+"\nSix: "+six);
}
}
I only need the proper java flowchart for this. I'm not sure how to organize it in the correct manner.
Get Answers For Free
Most questions answered within 1 hours.