FormulaEvaluator.java Requirements: Evaluate the following expression for any value of the variable x, and save the result in a variable of the type double. You must use the abs(), pow(), and sqrt() methods of the Math class to perform the calculation. You may use a single assignment statement with a somewhat large expression, or you may break the expression into multiple assignment statements. The latter may be easier to debug if you are not getting the correct result. (9x² + 7x² +5x+3)² (√8x² − 6x² + 4x² +1|20x|+1) Next, determine the number of digits to the left and to the right of the decimal point in the result. [Hint: You can convert the double variable into a String variable using the static method Double.toString(result). Then, on this String variable use the indexOf() method from the String class to find the position of the decimal point ("") and use the length() method to find the length. Knowing the location of the decimal point and the length of the String, you should be able to determine the number of digits on each side of the decimal point.] Finally, the result should printed using the class java.text.Decimal Format so that to the right of the decimal there are at most three 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 (e.g.. zero should be printed as 0.0 rather than 0.000).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
• FormulaEvaluator.java
Requirements: Evaluate the following expression for any value of the variable x, and save the
result in a variable of the type double. You must use the abs(), pow(), and sqrt() methods of the
Math class to perform the calculation. You may use a single assignment statement with a
somewhat large expression, or you may break the expression into multiple assignment statements.
The latter may be easier to debug if you are not getting the correct result.
5x +3} ( √8x* — 6x²³ + 4x² + |20x+1)
(9x³+7x² +5x+3)
Next, determine the number of digits to the left and to the right of the decimal point in the result.
[Hint: You can convert the double variable into a String variable using the static method
Double.toString(result). Then, on this String variable use the indexOf() method from the String
class to find the position of the decimal point (".") and use the length() method to find the length.
Knowing the location of the decimal point and the length of the String, you should be able to
determine the number of digits on each side of the decimal point.]
Finally, the result should printed using the class java.text.DecimalFormat so that to the right of
the decimal there are at most three 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 (e.g., zero should be printed as 0.0 rather than 0.000).
Transcribed Image Text:• FormulaEvaluator.java Requirements: Evaluate the following expression for any value of the variable x, and save the result in a variable of the type double. You must use the abs(), pow(), and sqrt() methods of the Math class to perform the calculation. You may use a single assignment statement with a somewhat large expression, or you may break the expression into multiple assignment statements. The latter may be easier to debug if you are not getting the correct result. 5x +3} ( √8x* — 6x²³ + 4x² + |20x+1) (9x³+7x² +5x+3) Next, determine the number of digits to the left and to the right of the decimal point in the result. [Hint: You can convert the double variable into a String variable using the static method Double.toString(result). Then, on this String variable use the indexOf() method from the String class to find the position of the decimal point (".") and use the length() method to find the length. Knowing the location of the decimal point and the length of the String, you should be able to determine the number of digits on each side of the decimal point.] Finally, the result should printed using the class java.text.DecimalFormat so that to the right of the decimal there are at most three 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 (e.g., zero should be printed as 0.0 rather than 0.000).
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education