Reference no: EM13926503
1. Write a Java program to simulate a die. A die has values of either 1, 2, 3, 4, 5 or 6 on the face. You should use the Math.Random() or the java.util.Random() class to generate the values on the die. The program should prompt the user to enter how many times the die should be rolled. The output should show the results of each roll along with the total number of times 1, 2, 3, 4, 5 or 6 occurred for all rolls and the total sum comprised of the sum of all rolls. Here is a sample run:
How many times do you want to roll the die? 10
Thank you! The die roll results for 10 rolls were: 2 3 4 5 3 2 6 2 1 6 The number of occurrences of each face were as follows:
1: 1 2: 3 3: 2 4: 1 5: 1 6: 2
The sum of die rolls was: 34
2. Design a Java class named Polygon that contains:
A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.
A private double data field named sideLength that defines the length of each side. The default value should be 10.0.
A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.
A private double data field named yCoord that defines the y-coordinate of the center of the polygon. The default value should be 0.0.
A no argument constructor that creates a Polygon using the default number of sides, default side length and default x- and y-coordinates.
A constructor that creates a Polygon using a specified number of sides, side length and x- and y-coordinates.
Getter and setter methods for all data fields
A getPerimeter() method that returns a double value representing the sum of all sides.
A toString() method that displays the number of sides, side length, x-coordinate and y-coordinate values in String format.
Be sure your code compiles. (In the next question, you will create a TestPolygon class and test each of the methods)
Write a Java test program, named TestPolygon, to create five different polygons. When creating the five polygons, create one using the no argument constructor. For the remaining four, feel free to use any number of sides, side length and x-, and y-coordinates that are not equal to the default values and not equal to each other. For each of the five polygons, call all of the methods and display the results. For example for a Polygon with 3 sides, side length of 2.0 and x-coordinate and y-coordinates of 1.0, the following output may be appropriate.
toString() results: (3, 2.0, 1.0,1.0) getNumSides() results: 3 getSideLength() results: 2.0 getXCoord() results: 0.0 getYCoord() results: 0.0 getPerimeter() results: 6.0 setNumSides(4) results: 4 setSideLength(3) results: 3.0 setXCoord(2.0) results: 2.0 setYCoord(2.0) results: 2.0
Keep in mind, for five Polygons, you will have five different output results. Also, note there is no requirement to actually draw a Polygon.
Where did you place on the ideology matrix
: Where did you place on the ideology matrix? Where you surprised by the results or did you place about where you thought that you would? What do you think has been the largest influence on your ideology and why
|
Computer maintenance and training guide
: This computer maintenance guide will help clients to install new hardware to a computer or substitute the present hardware. It will also give safety guidelines to avoid unnecessary problems with the computer hardware. This training guide informs t..
|
Performance evaluation-the illusion of objectivity
: You are a store manager for a large, regional department store chain. Company headquarters has asked you to submit an evaluation of your assistant managers performance.
|
Which sentence is preferable
: My brother must have had the angels watching over him yesterday. As he ________ from branch to branch like a monkey in a tree, he ________ thirty feet and all he got was a scratched toe.
|
Write a java program to simulate a die
: Write a Java program to simulate a die. A die has values of either 1, 2, 3, 4, 5 or 6 on the face. You should use the Math.Random() or the java.util.Random() class to generate the values on the die.
|
Development in the various modes of transportation
: The Hub and Spoke Concept continues its development in the various modes of transportation (Maritime, Air, Truck, and Rail). Describe some of the key advantages this concept brings to the various modes of transportation.
|
Identify and briefly summarize the federalist paper
: Identify and briefly summarize the Federalist Paper you selected. Explain the key ideas that were discussed in that paper. Explain why the key ideas in the Federalist Paper you selected did or did not become part of U.S. law
|
Processes for developing the client solution
: As a consultant, you bring to the table standard methods and processes for developing the client solution. Your solution may be a general one with special emphasis on at least two TCOs addressed in the course.
|
Tributary lateral load problem
: What is the maximum allowable drift (inches) at the top of the ground/first story - Calculate the service load.
|