Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

 

Provide the code for a class called Coin.java that implements the main method provided below.

public static void main(String [] args)

{

Coin toss = new Coin();

for (int x = 0; x < 1000; x++)

toss.flip();

Coin.results();

}//end main

When the program runs, the following random output should be produced: (numbers will vary as are random)

Heads: 494

Tails: 506

Program specific requirements:

 

  •  Style is require but comments are NOT required. 
  •  Include appropriate import statements for your file. 
  •  Utilize a constant class array to hold "Heads" and "Tails"
  •  Declare a class ArrayList called flips that will hold integer values, 0 for heads and 1 for tails 
  •  Create a flips method that performs the following: 
  •  Initializes an instance of the Random class and a random variable
  •  Stores a random variable either 0 or 1
  •  Store the random number in the flips ArrayList
  •  Create a results method that performs the following:
  •  Declare variable to hold number of heads flipped
  •  Utilize a for loop to iterate through the ArrayList (do NOT hard code the size here)
  •  For each iteration, increment the result from the ArrayList into a variable called heads
  •  Output the number of Heads using the constant array for the "Heads" heading along with the number of heads flipped
  •  Output the number of Tails using the constant array for the "Tails" heading along with the number of

 

 

 

 

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9453350

Have any Question?


Related Questions in Computer Engineering

Link changes in unemployment inflation wages and gdp to one

Link changes in unemployment, inflation, wages, and GDP to one another and how they impacted each other during periods of economic decline (recessions) and periods of economic growth (expansion) over the past 10 years.

Consider a normally distributed set of scores with a mean

Consider a normally distributed set of scores with a mean of 0 and a standard deviation of 5. If a value of 3.25 is sampled from this distribution, what is the corresponding z-score? If necessary, round your answer to tw ...

One state lottery has 1100 prizes of 1 145 prizes of 10 20

One state lottery has 1,100 prizes of $1; 145 prizes of $10; 20 prizes of $75; 5 prizes of $285; 2 prizes of $1,080; and 1 prize of $2,300. Assume that 24,000 lottery tickets are issued and sold for $1. 1)  What is the l ...

Describe the role of an ethical hacker and describe what

Describe the role of an ethical hacker and describe what you can do legally as an ethical hacker

Suppose that a data warehouse consists of the four

Suppose that a data warehouse consists of the four dimensions date, spectator, location, and game, and the two measures count and charge, where charge is the fare that a spectator pays when watching a game on a given dat ...

A resistor selected at random from a bin containing 1 k ohm

A resistor selected at random from a bin containing 1 K Ohm 5% tolerance resistors is measured with an ohmmeter. The ohmmeter is old fashioned pointer type that introduces measurement error and operator error (it is hard ...

Assume a data histogram is bell shaped with an average of

Assume a data histogram is bell shaped with an average of 60 and standard deviation of 10. Using the Empirical Rule, approximately what percentage of data fall between 50 and 80?

What is the supply curve how do you apply the law of supply

What is the supply curve, how do you apply the law of supply in economics?

Question monicas reading comprehension score 22nbspmean

Question: Monica's reading comprehension score = 22  Mean fourth grade reading comprehension score = 19  Standard deviation of the fourth grade's reading comprehension = 1.8  Monica's z-score in math = 2.2  Mean fourth g ...

Ambrose has indifference curves with the equation x2 k -

Ambrose has indifference curves with the equation x2 = k - 4(x^0.5) ... Where the larger "k" is, the higher the indifference curve. If good 1 is drawn on the horizontal axis, and good 2 on the vertical... What is the SLO ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As