Question 4: Provide at least 4 test cases.
Prompt the user to input 3 doubles, a, b and c.
Which will represent the coefficients in the quadratic equation
ax2 + bx + c = 0. Print out
the solutions (if any) of the quadratic equation. If no root exists
(this happens if a == 0, or b2
<4ac) print the message No real
root.
Sample input/ user entries shown in red |
Corresponding output |
Enter a, b and c which represent the coefficients in the quadratic equation ax^2 + bx + c = 0 : 1 0 -8 |
Root1 is 2.828427 Root2 is -2.828422 |
Enter a, b and c which represent the coefficients in the quadratic equation ax^2 + bx + c = 0 : 0 3 5 |
No real root |
Enter a, b and c which represent the coefficients in the quadratic equation ax^2 + bx + c = 0 : 1 5 -5 |
Root1 is 0.854101 Root2 is -5.854101 |
Test # |
Valid / Invalid Data |
Description of test |
Input Value |
Actual Output |
Test Pass / Fail |
1 |
Valid |
||||
2 |
Valid |
||||
3 |
Valid |
||||
4 |
Valid |
Test cases
Test # |
Valid / Invalid Data |
Description of test |
Input Value |
Actual Output |
Test Pass / Fail |
1 |
Valid |
Testing for real roots | a=1 b=5 c=6 |
Root1=-2 Root2=-3 |
Pass |
2 |
Valid |
Testing for real roots | a=1 b=-3 c=-10 |
Root1=5 Root2=-2 |
Pass |
3 |
Valid |
Testing for a=0 for no real roots | a=0 b=-3 c=-10 | No Real roots | Pass |
4 |
Valid |
Testing for b^2-4ac=0 for no real roots | a=1 b=4 c=1 | No Read roots | Pass |
if you like the answer please provide a thumbsup
Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a,...
Help with MATLAB. i did like input('enter the coefficients of a quadratic equation "Ax2 + Bx + C = 0"') fx=(-B+sqrt(B^2+4*A*C))/(2*A); i just dont know how i can ask the user to input three (A,B,C)? thanks! EXERCISE 6 Ask user to enter the coefficients of a quadratic equation, Ax² + Bx + C = 0, i.e. A, B, and C, and calculate the roots of the equation using the quadratic formula, ., --B+VB? - 4AC 2A
write a C programming code for the following prompt. please use stucture concept and test if the code works perfectly. Project Description: In this project, you will write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadra coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type...
A quadratic equation is generally represented as, ax^2 + bx + c The root(s) of the above quadratic equation is computed using the following formula, root1 = (-b + sqrt(D))/ 2a root2 = (-b - sqrt(D))/2a Where D is the discriminant of the quadratic equation and is computed as, D = b^2 - 4ac Given the value of D, the roots of a quadratic equation can be categorized as follows, D > 0 : Two distinct real roots D =...
C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...
write a function of quadratic choice. it must take in at least one parameter, and perform some task. the reslut will be returned to main, and printed. here is the sample but this sample still not complete because this sample still need to return root1 and root2 to the main. sample: def juneQuadratic(a,b,c): root1 = (-b + math.sqrt(b**2 - (4*a*c)) )/2*a root2 = (-b - math.sqrt(b**2 - (4*a*c)) )/2*a return (root1,root2) def main(): rootsTupleFromFunction = juneQuadratic(2,8,5) print(rootsTupleFunction) print("Root 1...
In Python. 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...
Use Python Programming. Design a class named Quadratic Equation for a quadratic equation ax + bx+c 0. The class contains: • The data fields a, b, and c that represent three coefficients. . An initializer for the arguments for a, b, and c. • Three getter methods for a, b, and c. • A method named get Discriminant() that returns the discriminant, which is b- 4ac The methods named getRoot 1() and getRoot 2() for returning the two roots of...
The roots of the quadratic equation ax2 + bx + c = 0, a following formula: 0 are given by the In this formula, the term i2 - 4ac is called the discriminant. If b4ac 0 then the equation has a single (repeated) root. If -4ac > 0, th equation complex roots. Write a program that prompts the user to input the value of a (the coefficient of ), b (the coefficient of x), and c (the n has two...
3. Produce the function quadratic(a,b,c) where a, b, and c are the coeffi- cients of the quadratic ax2 + bx +c. The function should return: 1. a list of the two roots of ax2 + bx +c= 0, when two roots exist 2. the first root is the smaller of the two 3. if ax2 + bx +c=0 has no real roots, then return None. 4. if the quadratic has one real root only, then return a list with a...
please answer this question with python. Write a program to solve the quadratic equation ax^2 + bx + c = 0 using the standard quadratic formula x = -b plusminus Squareroot b^2 - 4ac/2a or the alternative formula x = 2c/-b Squareroot b^2 - 4ac. Your program should accept values for the coefficients a, b, and c as input and produce the two roots of the equation as output. Your program should detect when the roots are imaginary, but need...