Home Answers Viewqa Java-Beginners A Java program to simulate throwing a die

 
 


Samith
A Java program to simulate throwing a die
2 Answer(s)      a year and a month ago
Posted in : Java Beginners

A Java program to simulate throwing a die (singular of dice) 6000 times and store the frequency with which each face of the die is uppermost after each throw in an array.

A couple of sample outputs follow: 1: 1020 2: 1015 3: 990 4: 1036 5: 941 6: 998

1: 984 2: 1016 3: 967 4: 1028 5: 985 6: 1020

View Answers

April 26, 2012 at 4:02 PM


mate, you cant cheat on your assignment1 FIT1002 by getting other people to code it for you. You should know this by now. If you have any problems you should go see your tutor. Lucky this doesnt get taken against you


April 26, 2012 at 5:10 PM


import java.util.Random;

public class DiceRolling
{
    public static void main( String[] args)
    {
        Random randomNumbers = new Random(); 
        int[] array = new int[ 7 ]; 
        int dice;
        for ( int roll = 1; roll <=6000; roll++ )
        {
            dice = 1 + randomNumbers.nextInt ( 6 );
            ++array[dice]; 
        }
         System.out.println("Face     Frequency");
        for ( int face = 1; face < array.length; face++ )
          System.out.println( face+"\t "+ array[ face ] );

    }     
}

The above code throw a dice 6000 times and and store the frequency with which each face of the die after each throw in an array.









Related Pages:
A Java program to simulate throwing a die
A Java program to simulate throwing a die  A Java program to simulate throwing a die (singular of dice) 6000 times and store the frequency with which each face of the die is uppermost after each throw in an array. A couple
java program - Java Beginners
java program  I worte out this program that was supposed to simulate a die rolling and then the program printing out each roll, the program also... wrote out most of the program , I don't know how to get it to print out the number
java util date - Time Zone throwing illegal argument exception
java util date - Time Zone throwing illegal argument exception  ...()); The date object is not getting created for IST time zone. Java is throwing an Illegal Argument Exception Why is the second SOP always throwing
Throwing an Exception
Throwing an Exception      ...; The code of the program is given below: <html> <head> <title>Throwing an Exception in jsp</title> </head>
Throwing an Exception in JSTL
Throwing an Exception in JSTL          In this program we are going to show you...; The code of the program is given below:       <
why it is throwing classCastException.
why it is throwing classCastException.   public class Redwood extends Tree { public static void main(String[] args) { new Redwood().go(); } void go() { go2(new Tree(), new Redwood()); go2((Redwood) new
Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... to enter an integer number. Write a program in java to find the factorial
Exceptional Example in Java
it to the program by throwing the object of exception method. The Exception Object states... Exceptional Example in Java       When an error occurs in a method, Java creates an object
PHP SQL Die
PHP SQL Die       PHP SQL Die results when there is a connection failure. The die( ) function prints... The Tutorial illustrate an example from 'PHP SQL Die'. To understand and grasp the example
program
program  write a program different between to dates in terms of days in java
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
is working in Java department and salary is 10000". Instantiate the Employee class
Java Throw Built-in Exception
Java Throw Built-in Exception In this section we are discussing about throwing of built-in exceptions in Java. In Java throw and throws keywords are used... will demonstrate you about how to use throw keyword in Java to throw the exception
jQuery '.live' & '.die' Mouse events
jQuery '.live'  & '.die' Mouse events In this tutorial ,we will discuss about how to  remove an event using 'die'... click , click on blue button to see effect of die event </font><
java program for
java program for   java program for printing documents,images and cards
Java Program
Java Program  A Java Program that print the data on the printer but buttons not to be printed
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
java program
java program  write a program to print 1234 567 89 10
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  how to write an addition program in java without using arithematic operator
Java Program
Java Program  java program to insert row in excel sheet after identifying an object
java program
java program  java program to implement the reflection of a particular class details like constructor,methods and fields with its modifiers
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.  ... in Java
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
java program
java program  write a program to create text area and display the various mouse handling events
java program
java program  Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program  . Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program  . Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
Java program
Java program  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
program in java
program in java  write a reverse program in java using string buffer.the input and out put as follows. input- hi good mornig out put-ih doog ginrom
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
java program
java program   A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A java program to display above triangle
java program
java program  write a program to create server and client such that server receives data from client using BuuferedReader and sends reply to client using PrintStream
java program
java program  write a java program to read a file which hold email address validate email address tohave formate @.* and replace all .com email address
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
Java Program
Java Program  I want to Write a program in JAVA to display to create a class called MATRIX using a two-dimensional array of integers. Perform the addition and subtraction of two matrices. Help me
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
Programming: Hammurabi I
Java NotesProgramming: Hammurabi I Description Your program will simulate... of a bad harvest. Initial Conditions Your program should create... a program into different classes is to group data and methods that belong together
java program
java program  Write a program that computes loan payments. The loan can be a car loan, a student loan, or a home mortgage loan. The program lets the user enter the interest rate, number of years, loan amount, and displays

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.