Question: Need help writing the class for java program . ExpressionEvaluator.java Requirements: Calculate the following expression for a value x of type double which is read
. ExpressionEvaluator.java Requirements: Calculate the following expression for a value x of type double which is read in from the keyboard, and save the result of the expression in a variable of the type double. You must use the sqrt), abs0 and pow0 methods of the Math class to perform the calculation. You may use a single assignment statement with a single expression, or you may break the expression into appropriate multiple assignment statements. The latter may easier to debug if you are not getting the correct result. 110, 4x10-x + 1/ (3.5x4 + 2.5x2 + 1.5x + 0.5) Next, determine the number of digits to the left and to the right of the decimal point in the unformatted result. [Hint: You should consider converting the type double result into a String using the static method Double.toString(result) and storing it into a String variable. Then, on this String variable use the indexoff".") method from the String class to find the position of the period (i.e., decimal point) and the length) method to find the length of the String. Knowing the location of the decimal point and the length, you should be able to determine the number of digits on cach side of the decimal point. Finally, the result should be printed using the class java.text.Decimal Format so that to the right of the decimal there are at most five digits and to the left of the decimal each group of three digits is separated by a comma in the traditional way. Also, there should also be at least one digit on each side of the decimal (eg.. 0 should be printed as 0.0). Hint: Use the pattern "#,##0.0####" in your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
