Answered step by step
Verified Expert Solution
Question
1 Approved Answer
To test, you should put all of these methods into one class and then do a main method that will instantiate an instance (object) of
To test, you should put all of these methods into one class and then do a main method that will instantiate an instance (object) of that class to use the below methods. You will need to get the parameters from the user for each value. 1. Implement a method named surface that accepts 3 integer parameters named width, length, and height as user input. It will return the total surface area (6 sides) of the rectangular box it represents. The formula for Surface Area is 2(length * width) + 2(length * height) + 2(height * width) Sample input and output: Enter width: 2 Enter length: 3 Enter height: 4 The total surface area is: 52 2. Implement a method named rightTriangle that accepts 2 double parameters named sideA and hypotenuseB as user input. The method will return the length of the third side. Sample input and output: Enter side: 3.0 Enter hypotenuse: 5.0 The other side is: 4.0 Class Die (The modification of the class Die should be saved as Die.java) 3. Modify the class Die presented in class to include another instance data (String), called color, to represent the color of a die. Add a getter/setter for this data. comboDie (This method is part of the MyMethods.java class) 4. Implement a method comboDie that takes two dice parameters. The method returns a die with color (the combination of each die's colors) and face value (the integer average of each die's face values). Example: if the first die is "blue" with faceValue=3 and the second die is "red" with faceValue=5, the method returns a "blue-red" die with facevalue = 4. Use the Die class presented in class, that you modified in Problem 3. DEFINING CLASSES (PairOfDice.java and TestPairOfDice.java.) 5. Using the Die class defined in class, design and implement a class called PairOfDice, composed of two Die objects. Include methods to set and get each individual die, a method to roll the dice, a toString method that returns colors of both dice and a method pairSum that returns the current sum of the two die values. (PairOfDice.java) 6. Write an application TestPairOfDice that uses the PairOfDice class to create a pair of dice. The application prints to the screen the sum of their face values. Then, use the PairOfDice class to roll Page1of2 the dice. The application prints to the screen the new sum of their face values and the colors of both dice. (TestPairOfDice.java) Sample output: Sum of face values before roll: 7 Sum of face values after roll: 6 Colors of both dice: Red, Blue
Step by Step Solution
★★★★★
3.31 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
Here is a Java class that implements all of the methods you requested as well as a main method that tests them public class MyMethods public static in...
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started