Generating two random numbers

Assignment Help Basic Computer Science
Reference no: EM131570954

Make a program to simulate the rolling of two six-sided dice. The program should work by generating two random numbers, each in the range of 1 to 6, to represent the two dice. The sum of the two values should then be calculated. Use a loop to roll the dice millions of times and use a one-dimensional array to keep a count of how many times each sum appears. Here's a snippet you can use. Assume counts is declared like this: int[] counts = new int[13];

int die1 = 1 + (int) (Math.random() * 6);

int die2 = 1 + (int) (Math.random() * 6);

int sum = die1 + die2;

counts[sum]++;

Practice 2

Make a program that will play Tic-Tac-Toe. The game board will be a 2D array. Allow two human players. Wherever the first player moves, place an X in the specified square, and place an O wherever the second player moves. Each move must be to an empty square. After each move, determine whether the game has been won and whether it's a draw.

Reference no: EM131570954

Questions Cloud

Operating system security : Operating systems play a role in a number of contexts within an enterprise network. There are those who have preference for a particular operating system
What is the problem of polarizing healing techniques : Does the promotion or lack of promotion of CAM techniques confirm this gap in healing modalities? Explain how?
Write a reflection paper for winning presentation : Write a reflection paper for winning presentation. Have you used the skills from this class in your day-to-day life or other classes?
What does your assessment imply for future business : Assess the financial value of the company using relevant indicators. What does your assessment imply for future business health and performance?
Generating two random numbers : Make a program to simulate the rolling of two six-sided dice. The program should work by generating two random numbers, each in the range.
How does this differ from a mail client on your pc : How does this differ from a mail client on your PC? What is a peer-to-peer network? Can you think of an example of such a network you have used?
Write alibaba background and history of operation in china : Do a research about Alibaba company. Write a Company background and history of its operations in China. 2-3 pages long with double spaces.
Design in developing a program : Consider the importance of program design in developing a program that interacts with the user.
What philosophical statements did your characters explore : What philosophical statements did your characters explore? What kind of assignments tend to be easy for you? What do you struggle with?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What are the different types of multimedia sources

Describe how the insert, delete, and update commands should be implemented on a transaction time relation.

  Find the standard form of the equation

Find the standard form of the equation of the hyperbola satisfying the given conditions. Endpoints of transverse axis: (-6, 0), (6, 0); foci: (-7, 0), (-7, 0)

  Utilize a constant called taxrate to hold the tax rate

Program should read in a file called "sales.txt". The contents of the text file are below. Read in all data from the file. Sore units in integers and store sales in doubles.The first integer is the first unit sales. The first double is the first $ o..

  How were studies selected for the analysis

How were studies selected for the analysis

  When it comes to computer science

When it comes to computer science, for my cs 225 class how much will I use that in software engineering as my future career?

  Imagine you are a senior systems administrator

Imagine you are a senior systems administrator who has recently been given the task to help improve security of your company's IT infrastructure after a series of network security breaches. These breaches included someone accessing the network ..

  Write the code to play a number guessing game

HW#5:Write the code to play a number guessing game.

  Whose trademark is the operating system unix

Whose trademark is the operating system UNIX? A.Motorola B.Microsoft C.BELL Laboratories D.AshtonTate

  What are the roots of the problem

To complete this assignment, you will need to access the research design summary for the statewide needs assessment. Your assignment is to create a replication of this design that will focus on childhood obesity in your state.

  Alternative investment proposals

Contract Manufacturing, Inc., is considering two alternative investment proposals. The first proposal calls for a major renovation of the company's manufacturing facility.

  Assess and evaluate key aspects of legal

Identify ethical, social and legal issues relevant to Information Systems within a context of application and assess and evaluate key aspects of legal, ethical and cultural issues relevant to an IT professional

  What is the intent of regulatory compliance

What is the intent of regulatory compliance, and what is the role of IT in maintaining corporate compliance?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd