Problem 1. Solve Quadratic Equations (QuadraticRoot.java) The two roots of a quadratic equation ax + bx +c = 0 can be obtained using the following formula: -b+ V- 4ac rl = 2a -b -4ac r2 2a b - 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 class named QuadraticRoot that prompts the user to enter values for a, band c and displays the result based on the discriminant. If If the discriminant is 0 the discriminant is ngsitive dislay two roots.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
icon
Concept explainers
Question
100%

Need answer for problem 1 only

Please provide implementation and output screenshots.

Problem 1. Solve Quadratic Equations (QuadraticRoot.java)
The two roots of a quadratic equation ax + bx +c = 0 can be obtained
using the following formula:
-b+ vb? - 4ac
rl =
2a
-b - Vb2 - 4ac
r2 =
2a
b - 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 class named QuadraticRoot 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".
Outputs:
Please enter a, b, c: 1.8 3 1
The equation has two roots: -0.381966 and -2.61803
Please enter a, b, c: 1 2.8 1
The equation has one root: -1
Please enter a, b, c: 1 2 3
The equation has no real roots
Problem 2. Random Month (RandomMonth.java)
Description
Write a Java class named RandomMonth that randomly generates an
integer between 1 and 12, and displays the English month name
January, February, March, ., December for the number 1, 2, 3, 12
accordingly.
You are required to use the switch statement to do this job.
Outputs:
The random number generated is 7
The corresponding month is July.
The random number generate is 12
The corresponding month is December
Transcribed Image Text:Problem 1. Solve Quadratic Equations (QuadraticRoot.java) The two roots of a quadratic equation ax + bx +c = 0 can be obtained using the following formula: -b+ vb? - 4ac rl = 2a -b - Vb2 - 4ac r2 = 2a b - 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 class named QuadraticRoot 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". Outputs: Please enter a, b, c: 1.8 3 1 The equation has two roots: -0.381966 and -2.61803 Please enter a, b, c: 1 2.8 1 The equation has one root: -1 Please enter a, b, c: 1 2 3 The equation has no real roots Problem 2. Random Month (RandomMonth.java) Description Write a Java class named RandomMonth that randomly generates an integer between 1 and 12, and displays the English month name January, February, March, ., December for the number 1, 2, 3, 12 accordingly. You are required to use the switch statement to do this job. Outputs: The random number generated is 7 The corresponding month is July. The random number generate is 12 The corresponding month is December
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Design of User Interface
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning