Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that generates random numbers representing the three coefficients a , b , and c of the quadratic equation. The values of a

Write a program that generates random numbers representing the three coefficients a, b, and c of the quadratic equation. The values of a should include numbers 1 through 10, the values of b and c should include numbers -5 through 5. The value of the discriminant will determine if the root of the equation will contain two real roots, one real root, or two complex roots. Print the values of a, b, and c. Print the value of the discriminant.

Print an appropriate message for each case. If two real roots are calculated, print the values appropriately. If only one real root is calculated, print a message that only the one root is produced and print the value.

Your program should not calculate the roots if the coefficients will produce complex roots based on the value of the discriminant. Simply print a message that the roots are complex.

Requirements:

Include the required heading as stated in Creating and Submitting Projects in Eclipse

Use of internal documentation

Use the DecimalFormat class to format the roots. There should always be a digit to the left of the decimal point and at least 1 digit to the right of the decimal point. Print up to three decimal places if the digits are not zero. See sample output below.

Use the pow() method and sqrt() method from the Math class

Use the Random class to assign values to a, b, and c

Sample Output:

The coefficients are:

a = 4 b = 4 c = 1

The discriminant is 0.0

Values produce only one root: -0.5

The coefficients are:

a = 9 b = 1 c = 0

The discriminant is 1.0

The roots are: 0.0 and -0.111

The coefficients are:

a = 2 b = 2 c = 2

The discriminant is -12.0

The roots are complex

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Explain corporate sustainability.

Answered: 1 week ago

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago