Question: code in java. The two roots of a quadratic equation a x 2 + b x + c = 0 can be obtained using the

code in java.
The two roots of a quadratic equation ax2+bx+c=0 can be obtained using the following formula:
r1=-b+b2-4ac22a and r2=-b-b2-4ac22a
b2-4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real
roots. If it is zero, the equation has one root. If it is negative, the equation has no real roots. Write a
Java program that prompts the user to enter values for a,b, and c and displays the result based on
the discriminant. If the discriminant is positive, display two roots. If the discriminant is 0, display
one root. Otherwise, display the complex roots. Use JOptionPane dialog boxes to take inputs and
display the output.
Given an integer ArrayList, write a program to move all 0 s to the end of it while maintaining the
relative order of the non-zero elements. Note that you must do this in place without making a copy
of the ArrayList.
Example 1:
Input: nums =[0,1,0,3,12]
Output: [1,3,12,0,0]
Example 2:
Input: nums =[0]
Output: [0]
code in java. The two roots of a quadratic

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!