subject

The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:

r1 = (-b + sqrt(b^2 - 4ac)) / (2a)

and

r2 = (-b - sqrt(b^2 - 4ac)) / (2a)

b^2 - 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 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 equation has no real roots”.

sample run 1

enter a: 1.0

enter b: 3

enter c: 1

the roots are -0.3819660112501051 and -2.618033988749895

sample run 2

enter a: 1

enter b: 2.0

enter c: 1

the root is -1.0

sample run 3

enter a: 1

enter b: 2

enter c: 3

the equation has no real roots

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:50
Using the artofstat website, run a permutation test to see if there is a difference in the mean amount of time spent on emails per day between in state and out of state students. (make sure to generate 10,000 permutations.) in state students: 2 3 3 6 2 1 1 5 3 2.5 out of state students: 1 2 2 1 2 1 4 3 9 1 10 1 3 what is the p-value?
Answers: 3
question
Computers and Technology, 22.06.2019 06:00
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
question
Computers and Technology, 22.06.2019 08:00
Apex q: what does a low employment rate indicate? a. not many people are earning high salaries b. not many people are going to college c. not many people are renting their homes d. not many people have jobs
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
You know the right answer?
The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:...
Questions
question
Mathematics, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
question
Mathematics, 06.09.2020 01:01
Questions on the website: 13722367