Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ PROGRAM please read 1. [20 points] A quadratic equation is defined as: y = ax 2 + bx + c, in which a, b

C++ PROGRAM please read

1. [20 points] A quadratic equation is defined as: y = ax 2 + bx + c, in which a, b and c are real values. This equation may have one or two real roots or no real root at all. Here is the criteria that is used to determine the solution to this equation: (i) If b 2 4ac > 0, there are two different roots of this equation. These roots are: x1 = b + b2 4ac 2a , x2 = b b2 4ac 2a , (ii) If b 2 4ac < 0, there is no real root of this equation. (iii) If b 2 4ac = 0, there are two roots of this equation but they are the same. This same root can be found by setting b 2 4ac to 0 in the first case. Thus, we may assume that both roots are equal to b 2a . Therefore, you may combine (i) and (iii) in one. Your task is to write a C++ program that can solve many sets of quadratic equations. The program will ask the user to input the values of coefficients a, b and c, and then will display the answer based on the criteria given above. Note that if a user enters an a that is 0, you will have a solution to the equation that is given at the top, but the equation is no longer a quadratic equation. In such a case, if you use the solution to quadratic equations, you will have a divide by 0 (run-time error) error when you run your program. Test your program with the given test cases to make sure it produces the correct results. Here are some test cases.

Sample Input and Output: Test Case 1: Input: Take coefficient values of a equation Enter a: 0 Enter b: 2 Enter c: 4 Output: The equation is not quadratic. Therefore, this equation has one real root! The value of the only root is -2.00

Test Case 2: Input: Take coefficient values of a equation Enter a: 0 Enter b: 0 Enter c: 2 Output: The equation is not quadratic. Both a and b are zero. Thus, this equation has no real root!

Test Case 3: Input: Take coefficient values of a equation Enter a: 2 Enter b: 4 Enter c: 2 Output: The equation is quadratic. Both roots of this equation are the same and equal. The equal value of both roots is -1.00

Test Case 4: Input: Take coefficient values of a equation Enter a: 3 Enter b: 4 Enter c: 1 Output: The equation is quadratic. This equation has two roots! The value of one root is -0.33 The value of another root is -1.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

What happens when cultures collide?

Answered: 1 week ago