Question: Write a Java class that uses the Math class methods as follows. Use the dialog to guide your coding; notice the number of decimal places
Write a Java class that uses the Math class methods as follows. Use the dialog to guide your coding; notice the number of decimal places and code accordingly. Ensure that the value entered is a positive integer before proceeding. Invalid data (negative OR not an integer): Enter a numeric integer value: 3.25 Error: must be an integer value.
Valid data:
Enter a numeric integer value: 3
Square root: 1.732 Raised to power of 3: 27.0 Even or odd: Odd Note: Search online, in your textbook, or in your notes for the .hasNext methods of the Scanner class. You will find something that will help you identify whether the value the user types is or isn't an integer. Always raise to the 3rd power, regardless of user input.
Use the Math class methods for square root and raising to a power. Google the syntax and usage or check your text. Be careful when raising to a power. It requires data type double be used in the method call and stored to an expression-result variable of type double. Since your input-capture variable must be an int, you will have to apply some techniques you learned previously to move back and forth between data types.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
