Question

7-Sp19-Gunderson > Assignments> A09 Dice A09 Dice Due Apr 2 by 11:59pm Points 40Submitting a file upload Part 1. Dice (25 poi
0774 item id-8881416 A09 Dice Criteria Ratings Pts Follow best practices Follow the best practices described in the instructi
7-Sp19-Gunderson > Assignments> A09 Dice A09 Dice Due Apr 2 by 11:59pm Points 40Submitting a file upload Part 1. Dice (25 points) Dice.pdfy Create a video recording that shows the code of class Dice. After showing the code compile and run the program. Adjust the size of the output window to provide enoughroom for the whole output. The length of the video should be about 1 minute. Submission Submit both the video recording and the java file
0774 item id-8881416 A09 Dice Criteria Ratings Pts Follow best practices Follow the best practices described in the instructions and practiced in class Roll 2 dice Simulate the rolling of two dice Repeat 36,000 times 4.0 pts 4.0 pts 4.0 pts 4.0 pts 4.0 pts Use an array to count how often the different sums a ppear Display the results in tabular form 3.0 pts Display the results in tabular form as specified in the ins Submit the code and a video recording as specificd ZyBook challenge activities ZyBook 2.0 pts 10.0 pts 5.0 pts Total Points: 40.0 Previous Et
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

I have mentioned the details in the comment:

Dice.java

import java.util.Random;

public class Dice {
    public static void main(String[] args) {
        //to store the dice values
        int dice1,dice2,sum;

        //Random is used to generate random number from 1 to 6
        Random r = new Random();

        System.out.println("Simulation of Rolling 2 Dices");

        //array to store frequency
        int frequency[] = new int[13];

        //repeat 36000 times
        for(int i=1;i<=36000;i++){
            //get first dice value
            dice1 = r.nextInt(6) + 1;
            //get second dice value
            dice2 = r.nextInt(6) + 1;
            //get sum
            sum = dice1 + dice2;
            //increment count
            frequency[sum]++;
        }

        //print output
        System.out.println("Sum Frequency Percentage");

        for(int i=2;i<=12;i++){
            //get the percentage
            double perc = ((100.0*frequency[i])/36000.0);
            //format the output
            System.out.printf("%3d %9d %10.1f",i,frequency[i],perc);
            System.out.println("%");
        }

    }
}

Output:

C:\Program Files Java jdk1.8.0_151 binljava .. . Simulation of Rolling 2 Dices Sum Erequency Percentage 989 2065 2984 4007

Add a comment
Know the answer?
Add Answer to:
7-Sp19-Gunderson > Assignments> A09 Dice A09 Dice Due Apr 2 by 11:59pm Points 40Submitting a file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Module 13 Review Questions Due Apr 14 by 11:59pm Points 10 Submitting a file upload This chapter ...

    Module 13 Review Questions Due Apr 14 by 11:59pm Points 10 Submitting a file upload This chapter examines the basic features of three major business forms-sole proprietorships, partnerships, and corporations -and some of the important advantages and disadvantages of each. The chapter also covers briefly other types of business organizations, including limited liability companies, joint ventures, syndicates, joint stock companies, business trusts, and cooperatives. Discuss private franchises and submit your answer to the review question. Module 13 Review Questions Due...

  • disregard Final Project 2 Due Sunday by 11 59pm Points 100 Submitting the upload Instructions For...

    disregard Final Project 2 Due Sunday by 11 59pm Points 100 Submitting the upload Instructions For this assignment, you will create flowchart using Flowgorithm and Pseudocode for the following program example You are to design a program for Alexander's Coffee Shop providing customer research data When a customer places an order, the clerk asks the customer for their zip code and age. The clerk enters this data as well as the number of ems purchased. The program should operate continuously...

  • Week 5 Case Study: 5.5 (Due week 7) Submit Assignment Due Jul 27 by 11:59pm Points...

    Week 5 Case Study: 5.5 (Due week 7) Submit Assignment Due Jul 27 by 11:59pm Points 25 Submitting a text entry box or a file upload Create a non leading multiple choice answer type physician query for the following scenario. A 79-year-old female, Mrs. Carmichael, is admitted on June 15,2015, with a right hip fracture. Her hospital stay is 3 days long. Prior to surgery, her attending physician, Dr. Fellows, orders blood work to check her hemoglobin and hematocrit levels...

  • meClock Plus Home Due Sunday by 11:59pm Points 6 Submitting an external tool Available Jul 7...

    meClock Plus Home Due Sunday by 11:59pm Points 6 Submitting an external tool Available Jul 7 at 12am-Aug 2 at 11:59pm 27 days Announcements Grades Chapter 8: Confidence intervals (Proportions) Score: 0/6 0/6 answered Done Syllabus Modules Question 1 > B0/1 pt 9399 Assignments Discussions Files You are interested in constructing a 99% confidence interval for the proportion of all caterpillars that eventually become butterflies. Of the 376 randomly selected caterpillars observed, 55 lived to become butterflies. Round answers to...

  • 9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5...

    9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5 Submitting a file upload File Types zip Goals: Write a C++ class with separate.h and.cpp file, use partially filled arrays, Create a new class called Library that uses a private string array to store the list of books The starter code can be downloaded from https://github.com/pisan 342/ass 1-starter (https://github.com/pisan 342/ass 1-starter) You need to submit ass1.zip with the following files in it. Put all...

  • CSC151 JAVA PROGRAMMING LAB #7 OBJECTIVES . . . In this lab assignment, students will learn:...

    CSC151 JAVA PROGRAMMING LAB #7 OBJECTIVES . . . In this lab assignment, students will learn: To get an overview of exceptions and exception handling • To explore the advantages of using exception handling • To declare exceptions in a method header • To throw exceptions in a method • To write a try-catch block to handle exceptions To develop applications with exception handling To use the finally clause in a try-catch block To write data to a file using...

  • DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say f...

    DI Question 2 1.5 pts Which situations allow the client main() in the file my_program.py to access a method name, say func(), alone, as in x-func) without dereferencing it using prepended name like modname.func or x = some object. func () or x-SomeClass.func() O func) is defined in some module, say, "modname.py" and modname is imported into my_program.py using: from modname import func() is an instance method or a class method in a class, say SomeClass, defined in the same...

  • ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following...

    ELEC 1520 Homework - Integer Operations, Selection Statements Instructions Write C++ programs to solve the following two problems. Upload your source code files to Canvas. The file names must be of the form coins_your_name.cpp and bonus_your_name.cpp for problems 1 and 2, respectively. Substitute your first and last name for "your_name" in the file name. Problem Statements 1. Given a value V in cents, you need to make change using a minimum number of coins. Assume you have an infinite supply...

  • Status Topic Interfaces Description Video Scene Problem Consider a video scene in which we want to...

    Status Topic Interfaces Description Video Scene Problem Consider a video scene in which we want to display several different types (classes) of objects. Let's say, we want to display three objects of type Deer, two objects of type Tree and one object of type Hill. Each of them contains a method called display. We would like to store their object references in a single array and then call their method display one by one in a loop. However, in Java,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT