g Create a new Die object. (Refer to Die.html for documentation.)Create a loop that will iterate at least 100 times. In the loop
body:Roll the die. (Don't create a new object, just roll it again.)Based on the result of the roll, increment the corresponding cell of your array.
1 answer:
Answer:
Step-by-step explanation:
import java.util.Random;
class Die{
private int sides;
public Die(){
sides = 6;
}
public Die(int s){
sides = s;
}
public int Roll(){
Random r = new Random();
return r.nextInt(6)+1;
}
}
class DieRoll{
public static void main(String[] args) {
Die die = new Die();
int arr[] = new int[6];
for(int i=0; i<6; i++)
arr[i] = 0;
for(int i=0; i<100; i++){
int r = die.Roll();
arr[r-1]++;
}
for(int i=0; i<6; i++)
System.out.println((i+1)+" was rolled "+arr[i]+" times.");
}
}
You might be interested in
Answer:
Last step of FOIL: Multiply 2 from the first binomial with 3 from the second binomial.
simplify: a? should be 25x^(6)y^(6)
Step-by-step explanation
It means you get points or whatever by looking up the answer and trying to look smart
I cant see the picture good can you write it out not in picture because it is blury for me I dont know about the others
Answer:
Step-by-step explanation:
Calculate the distance d using the distance formula
d =
with (x₁, y₁ ) = (- 2, 6) and (x₂, y₂ ) = (- 1, - 3)
d =
=
=
= ≈ 9.06 ( to 2 dec. places )
Good evening,
5/6 of 60 is equivalent to 50.