Reference no: EM13322705
Write a Java class named Coin. The Coin class should have the following field:
A String named sideUp. The sideUp field will hold either "heads" or "tails" indicating the side of the coin that is facing up.
The Coin class should have the following methods:
A no-argument constructor that randomly determines the side of the coin that is facing up ("heads" or "tails") and initializes the sideUp field accordingly. [note: constructors are described in the early part of Chapter 11 of the Farrell book]
A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up ("heads" or "tails") and sets the sideUp field accordingly.
A method named getSideUp that returns the value of the sideUp field.
Write a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. The program should keep count of the number of times heads is facing up and the number of times tails is facing up, and display those values after the loop finishes.
Explain strongest reducing agent to weakest reducing agent
: Given the hypothetical redox reactions involving substances A, B, and C: A + B+ g? A+ + B C + A+ g? C+ + A B + C+ g? no reaction What is the arrangement of the substances in their order from strongest reducing agent to weakest reducing agent
|
Design a to perform various matrix operations
: Design a to perform various matrix operations. class A matrix is a set of numbers arranged in rows and columns. Therefore, every element of a matrix has a row position and a column position.
|
Calculate the change in length of the aluminum rod
: A straight rod consists of a 2cm long piece of aluminum attached to a 3cm long piece of steel. calculate the change in length of the aluminum rod
|
Calculate the power input to the pump in kw
: A 60 MW Rankine steam power cycle in Iceland uses reheat. The system is comprised of a single adiabatic pump, a boiler using geothermal energy, two adiabatic turbine stages and a condenser.
|
Write a program that demonstrates the coin class
: Write a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up.
|
Explain what is the final volume of the gas
: The pressure of 6.0 L of an ideal gas in a flexible container is decreased to one-sixth of its original pressure, and its absolute temperature is decreased to one-forth of the original. What is the final volume of the gas
|
Create a class called song that has 3 attributes-title
: Create a class called Song that has 3 attributes-title, artist, and price (which will be entered later as either 0.99 or 1.49). It should contain 2 constructor methods, all the necessary set and get methods, and a "toString" method that prints the..
|
What is the tension in the right cable
: A 200-N beam is held horizontally by a vertical steel cable at each end. The beam is 18 m long. A 650-N box sits 3.0 m from the left end. What is the tension in the right cable
|
Advertising to children in school is morally objectionable
: Advertising to children in school is morally objectionable to many people. Some of the reasons used to criticize the practice include the following: First, children at school are a captive audience. Second, children are not yet autonomous and a..
|