- Engineering
- Computer Science
- write the following program in java a fair dice has...
Question: write the following program in java a fair dice has...
Question details
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.
- You can hard code D and N in your program, i.e., no Scanner or args[] for input.
- Your code will output exactly as your last exercises ex04-ex07
- 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
- Use two functions for 'nextValue' and 'display', you are free to name them
- At the very end, display the execution elapsed time in second
- Provide a table and a chart of the relationship between D and elapsed time with D from 2 to 10.
- Depend on your computer, continue increasing D until elapsed time is beyond 3 minutes.
Solution by an expert tutor
