Question: Write the following program in java: A fair dice has 6 faces from 1 to 6. Throw D dice, there are 6x6x...x6 = 6^D combinations

Write the following program in java:

  • A fair dice has 6 faces from 1 to 6.
  • Throw D dice, there are 6x6x...x6 = 6^D combinations (1,...,1), ... (6,...,6).
  • Give a value N (D<=N<=D*6), find how many combinations to have sum greater or equal to N.
  1. You can hard code D and N in your program, i.e., no Scanner or args[] for input.
  2. Your code will output exactly as your last exercises ex04-ex07
  3. For example, D=5, N=28, the output is exactly the following
    D=5, N=28 5184 : (6,6,6,6,4) 6264 : (6,6,6,5,5) 6444 : (6,6,5,6,5) 6474 : (6,5,6,6,5) 6479 : (5,6,6,6,5) 6480 : (6,6,6,6,5) 7344 : (6,6,6,4,6) 7524 : (6,6,5,5,6) 7554 : (6,5,6,5,6) 7559 : (5,6,6,5,6) 7560 : (6,6,6,5,6) 7704 : (6,6,4,6,6) 7734 : (6,5,5,6,6) 7739 : (5,6,5,6,6) 7740 : (6,6,5,6,6) 7764 : (6,4,6,6,6) 7769 : (5,5,6,6,6) 7770 : (6,5,6,6,6) 7774 : (4,6,6,6,6) 7775 : (5,6,6,6,6) 7776 : (6,6,6,6,6) Answer 21 / 7776 Elapsed 0.055 second 
  4. Use two functions for 'nextValue' and 'display', you are free to name them
  5. At the very end, display the execution elapsed time in second
  6. Provide a table and a chart of the relationship between D and elapsed time with D from 2 to 10.
  7. Depend on your computer, continue increasing D until elapsed time is beyond 3 minutes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!