Create a coin toss simulation program

Assignment Help Computer Engineering
Reference no: EM132092904

Personal Information Class(JAVA)

Design a class that hold the personal data: name, address, age and phone number. Write appropriate methods (constructor, getters ad setters. Demonstrate the class by writing a program that creates three instances of the class. You can populate information in each object using Scanner class. Please do not use any personal information as data in the project.

Part 2 - Coin Toss Simulator

Create a coin toss simulation program. The simulation program should toss coin randomly and track the count of heads or tails.

We need to write a program that can perform following operations:

a. Toss a coin randomly.

b. Track the count of heads or tails.

c. Display the results.

Design and Test:

Let's decide what classes, methods and variables will be required in this task and their significance:

Write a class called Coin.

The Coin class should have an Instance variable 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 following methods:

A void method named toss, which simulates the tossing of a 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 no-arg constructor, which randomly determines the side of the coin, that is facing up ("heads" or "tails") and initializes the sideUp field accordingly.

A method named getSideUp that returns the value of the sideUp field.

Create a toss method that uses loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. The method should keep count of the number of times heads or tails is facing up and display those values after the loop finishes.

Write the test program, which has main method and demonstrates the Coin class.

Reference no: EM132092904

Questions Cloud

Creating a new website advertising your new lawn care : Installing a new server running Windows Server 2012 R2... this will function as an upgrade to your existing printserver that hosts 15 network printers.
Describe the exception error : The exception err0r can be one that you have encountered or one you find on the Internet. Describe the exception err0r and explain potential implications.
Which computer and compiler would you purchase : Which computer and compiler would you purchase if all other criteria were identical, including cost.
Find two ways to change the mac address on your computer : Perform a little research to find two ways to change the MAC address on your computer. Clearly explain why this is valuable knowledge to have.
Create a coin toss simulation program : A no-arg constructor, which randomly determines the side of the coin, that is facing up ("heads" or "tails") and initializes the sideUp field accordingly.
How frequently should the key be changed : What attack is more likely to succeed if a key has been used frequently? How frequently should the key be changed?
Update the credit hours and classification : Update the credit hours, classification, and the GPA, taking into account the current GPA and grades in the courses the student is currently enrolled in.
Insert at least five sample rows of data into the employee : The database should have a table named Employee , with columns for employee ID, name, position, and hourly pay rate.
Describe data structure you will use to store opt value : Describe data structure you will use to store OPT value for the subproblems and the order in which you will fill out the entries in your data structure.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Construct a finite-state machine that models a newspaper

Construct a finite-state machine that models a newspaper vending machine that has a door that can be opened only after either three dimes.

  Examine the two articles you selected on universal usability

From the e-Activity, examine the two articles you selected on universal usability and discuss one topic of interest that was addressed.

  How can you change the signatures of the conflicting methods

Generic parameters are not included in the signature of a method. How can you change the signatures of the conflicting methods to get around this restriction?

  Plot both tube surface and fluid mean temperature

onsider a 0.6 cm inside-diameter. 1.2 m long circular tube, wound by an electric resistance heating element. Let the function of the tube be to heat an organic.

  Provide examples where cannot use logical operators

Search for arithmetic operators used in programming, and give two examples where you cannot use logical operators but you can use arithmetic operators. Also, think of two examples where both kinds of operators are used.

  Discuss the process of natural convection

A solar collector consists of a horizontal copper tube of outer diameter 5 cm enclosed in a concentric thin glass tube of 9 cm diameter.

  Slect two principles for policy and standards development

1.principles for policy and standards development please respond to the following select two principles for policy and

  What constitutes a well-maintained system

What constitutes a well-maintained system, in terms of function, utility, and reliability and how does the truly effective SysAdmin ensure success?

  What hexadecimal number does each binary number represent

What hexadecimal number does each binary number represent? Show the conversion process. What base 10 number does each binary number represent?

  Make an idef1x e-r diagram

The scenario is that the Public Affairs Office at Highline University receives requests for speakers on particular topics. To be capable to respond to such request, that office wants to build a database.

  Compare the resulting postfix expression

For every postfix expression there exists a corresponding and uniquely express infix expression that evaluates to the same number. The converse is not true.

  Questionassume this loop is taken many times what is

questionassume this loop is taken many times what is steady-state cpi of this loop on the scalar pipeline discussed in

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