Question: In java The Java language has a math class with several methods you can use for mathematical calculations. For instance, to find the square root
In java The Java language has a math class with several methods you can use for mathematical calculations. For instance, to find the square root of a number you can use the Math.sqrt method: double value = 9.0; double result = Math.sqrt(value); In the above example the variable result will hold 3.0. The same holds true for the cube root: double value = 9.0; double result = Math.cbrt(value); You can also get the base 10 logarithm of a number: double value = 9.0; double result = Math.log10(value); For this question you are going to create a simple calculator. From the keyboard take in a character that represents the operation and a double that represents the value to operate on. The operations are S - square root C - cube root L - base 10 logarithm Your input should be in this format S 81 This indicates that you want the square root of 81. Just as C 45 indicates that you want the cube root of 45. And L 45 indicates that you want the log 10 of 45 Using a switch statement determine the operation and using the appropriate math function output either the Square root, Cube root, or Log 10 of the value input. Use a default statement to catch when the input is not valid. Format your code with hilite.me and submit it in the text box provided.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
