Question: JAVA JAVA Question 1 [20 points] A quadratic equation of the form a x 2 +bx+c=0 might have two real roots, or one real root,
JAVA JAVA
Question 1 [20 points]
A quadratic equation of the form ax2+bx+c=0 might have two real roots, or one real root, or no real roots at all. The number of roots is based on the value of delta that is calculated using the below formula:
delta=b2-4ac
- if delta is greater than zero, then we have two real roots
- if delta is equal to zero, then we have only one real root
- if delta is less than zero, we dont have any real root
We need to Write a JAVA program that asks the user to enter three non-zero numbers a, b, and c. Then, calculates and displays the roots for the quadratic equation.
In order to solve this problem, we will implement:
- A thread class called FirstRoot that receives three double numbers a, b, and delta, and calculates the value of the first root based on the below formula: (4 pts)
r1=-b-delta2a
- A thread class called SecondRoot that receives three double numbers a, b, and delta, and calculates the value of the second root based on the below formula: (4 pts)
r2=-b+delta2a
- A driver class (Main class) that: (12 pts)
- Asks the user to enter three non-zero values a, b and c
- Calculates the value of delta, if:
- delta> 0, create and start two thread objects of type FirstRoot and SecondRoot, read the values of roots calculated by both threads, and display their value.
- delta = 0, create and start one thread objects of type FirstRoot, read the value of the root calculated by the thread, and displays its value.
- Delta < 0 , just display No Real Roots
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
