Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eric Morton DiceRolling-Lab #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Answers-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
,## Dice Rolling Lab
### Eric Morton
### Feb 3 , 2015


**Question 1 :** There is a 1/6 chance of rolling a 7, and a 1/36 chance of rolling a 2.

**Question 2:** Once 100 rolls were rolled, I believe that 100 rolls is not sufficient enough to determine the relative frequency of all the possible rolls becuase though 100 is a large number, it does not give an accuracte frequency for all of the posssible rolls.

**Question 3:** By increasing the number to 500, there is more of a chance for the coder to see if they can accuratley predict the chances of rolling their die.

**Question 4:** It would take approximately 400,000 rolls before we can predict the porbablity of rolling a 7 or a 3. For finding the proabality of a 2, that would take 200,000 rolls.
23 changes: 23 additions & 0 deletions src/Histogram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class Histogram {
private int[] values = new int[13];
private int count = 0;
int q = 0;

public void tally(int roll) {
values[roll] +=1;
count +=1;
}
public int getCount(int roll) {
return values[roll];
}
public double getRatio(int roll) {
return values[roll] / (double) count;
}
public void print() {
int val = 2;
while(val <=12) {
System.out.println(val + "/" + getCount(val) + "*"+ getRatio(val));
val+= 1;
}
}
}
27 changes: 27 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Main
{
public static void main(String [] args)
{
Histogram h = new Histogram();
int q = 0;
int total = 0;

Die d1 = new Die();
Die d2 = new Die();

while (q != 100) {

d1.roll();
d2.roll();

total = d1.getUpValue() + d2.getUpValue();

h.tally(total);
h.print();
q += 1;

}
}
}