Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equation ar²+bx+c= 0. The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with 4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with 4 digits printed out after the decimal place. 3. If the equation has solutions that are not real numbers, display COMPLEX SOLUTIONS:, followed by two solutions displayed in the form a +bi, where each a and b should be displayed with 4 digits printed out after the decimal place. For example, a run might look like Enter x 2 coefficient: 1 Enter x 1 coefficient: -2 Enter x 0 coefficient: 1 ONE SOLUTION: x= 1.0000 or Enter x 2 coefficient: 3 Enter x 1 coefficient: 5 Enter x 0 coefficient: 1 TWO REAL SOLUTIONS: x= -0.2324 and x = -1.4343 or Enter x 2 coefficient: 2.1 Enter x 1 coefficient: 4 Enter x 0 coefficient: 10 COMPLEX SOLUTIONS: x = -0.9524 - 1.96341 and x = -0.9524+ 1.96341 In the last case, note that the letter that is printed out to represent the square root of -1 is the letter i, not the letter j! Python has some functions that produce complex values, but when you print these values, they will display the letter j to represent √-1. I don't want that - so, instead, your program should calculate the imaginary coefficient, and then include code which prints out the string "i". Do not use the cmath module, the complex function, the imag attribute,or any Python functions that perform replacements in strings. (If you don't know what any of those are, don't worry about it.) Specifications: your program must • ask for and accept coefficients from the user. • assuming that the user enters a non-zero leading coefficient. display the type of solutions as above. (In the case where there is exactly one solution, it is acceptable if the program occasionally misidentifies it. although it should work with the example I've provided.) • display all solutions with exactly 4 digits printed after each decimal (for complex solutions. 4 digits after the decimal for both real and imaginary parts). • use the letter i to represent √-I in output, not the letter j. not use the math module, the complex function, the .imag attribute, or any Python functions that perform replacements in strings.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1) quadratic.py
Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equation az²+bx+c= 0.
The program should display the solutions of this equation, in the following manner:
1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with 4 digits printed out
after the decimal place.
2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with
4 digits printed out after the decimal place.
3. If the equation has solutions that are not real numbers, display COMPLEX SOLUTIONS:, followed by two solutions
displayed in the form a + bi, where each a and b should be displayed with 4 digits printed out after the decimal place.
For example, a run might look like
Enter x 2 coefficient: 1
Enter x 1 coefficient: -2
Enter x 0 coefficient: 1
ONE SOLUTION: x= 1.0000
or
Enter x^2 coefficient: 3
Enter x 1 coefficient: 5
Enter x 0 coefficient: 1
TWO REAL SOLUTIONS: x = -0.2324 and x = -1.4343
or
Enter x 2 coefficient: 2.1
Enter x1 coefficient: 4
Enter x 0 coefficient: 10
COMPLEX SOLUTIONS: x = -0.9524 - 1.96341 and x = -0.9524+ 1.96341
In the last case, note that the letter that is printed out to represent the square root of -1 is the letter i. not the letter j!
Python has some functions that produce complex values, but when you print these values, they will display the letter j to
represent √1. I don't want that so, instead, your program should calculate the imaginary coefficient, and then include
code which prints out the string "i". Do not use the cmath module, the complex function, the imag attribute,or
any Python functions that perform replacements in strings. (If you don't know what any of those are, don't worry
about, it.)
Specifications: your program must
ask for and accept coefficients from the user.
• assuming that the user enters a non-zero leading coefficient. display the type of solutions as above. (In the case where
there is exactly one solution, it is acceptable if the program occasionally misidentifies it. although it should work with
the example I've provided.)
display all solutions with exactly 4 digits printed after each decimal (for complex solutions. 4 digits after the decimal for
both real and imaginary parts).
• use the letter i to represent √-I in output, not the letter j.
• not use the cath module, the complex function, the imag attribute, or any Python functions that perform
replacements in strings.
Transcribed Image Text:1) quadratic.py Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equation az²+bx+c= 0. The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with 4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with 4 digits printed out after the decimal place. 3. If the equation has solutions that are not real numbers, display COMPLEX SOLUTIONS:, followed by two solutions displayed in the form a + bi, where each a and b should be displayed with 4 digits printed out after the decimal place. For example, a run might look like Enter x 2 coefficient: 1 Enter x 1 coefficient: -2 Enter x 0 coefficient: 1 ONE SOLUTION: x= 1.0000 or Enter x^2 coefficient: 3 Enter x 1 coefficient: 5 Enter x 0 coefficient: 1 TWO REAL SOLUTIONS: x = -0.2324 and x = -1.4343 or Enter x 2 coefficient: 2.1 Enter x1 coefficient: 4 Enter x 0 coefficient: 10 COMPLEX SOLUTIONS: x = -0.9524 - 1.96341 and x = -0.9524+ 1.96341 In the last case, note that the letter that is printed out to represent the square root of -1 is the letter i. not the letter j! Python has some functions that produce complex values, but when you print these values, they will display the letter j to represent √1. I don't want that so, instead, your program should calculate the imaginary coefficient, and then include code which prints out the string "i". Do not use the cmath module, the complex function, the imag attribute,or any Python functions that perform replacements in strings. (If you don't know what any of those are, don't worry about, it.) Specifications: your program must ask for and accept coefficients from the user. • assuming that the user enters a non-zero leading coefficient. display the type of solutions as above. (In the case where there is exactly one solution, it is acceptable if the program occasionally misidentifies it. although it should work with the example I've provided.) display all solutions with exactly 4 digits printed after each decimal (for complex solutions. 4 digits after the decimal for both real and imaginary parts). • use the letter i to represent √-I in output, not the letter j. • not use the cath module, the complex function, the imag attribute, or any Python functions that perform replacements in strings.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education