0

261kviews

Draw the flowchart for finding the roots of quadratic equation. Write the program for same.

**1 Answer**

0

261kviews

Draw the flowchart for finding the roots of quadratic equation. Write the program for same.

4

10.0kviews

written 8.0 years ago by | • modified 2.8 years ago |

**Step Form Algorithm:**

- Start.
- Declare the required variables.
- Indicate the user to enter the coefficients of the quadratic equation by displaying suitable sentences using printf() function.
- Wait using the scanf() function for the user to enter the input.
- Calculate the roots of quadratic equation using the proper formulae.
- Display the result.
- Wait for user to press a key using getch() function.
- Stop.

**Pseudo Code Algorithm:**

Start.

Input a, b, c.

D ← sqrt (b × b – 4 × a × c).

X1 ← (-b + d) / (2 × a).

X2 ← (-b - d) / (2 × a).

Print x1, x2.

Stop.

**Flowchart:**

Flowchart to calculate the roots of quadratic equation is shown below in figure 3.

**program**

```
import math
days_driven = int(input("Days driven: "))
while True:
code = input("Choose B for clas B, C for class C,D for class D, or Q to Quit: ")
# for class D
if code[0].lower() == "d":
print("You chose Class D")
if days_driven >=8 and days_driven <=27:
amount_due = 276 + (43* (days_driven - 7))
elif days_driven >=28 and days_driven <=60:
amount_due = 1136 + (38*(days_driven - 28))
else:
print("Class D cannot be rented for less than 7 days")
print('amount due is $', amount_due)
break
elif code[0].lower() == "c":
print("You chose class C")
if days_driven \gt= 1 and days_driven\lt=6:
amount_due = 34 * days_driven
elif days_driven \gt= 7 and days_driven \lt=27:
amount_due = 204 + ((days_driven-7)*31)
elif days_driven \gt=28 and days_driven \lt= 60:
amount_due = 810 + ((days_driven-28)*28)
print('amount due is $', amount_due)
# for class b
elif code[0].lower() == "b":
print("You chose class B")
if days_driven >1 and days_driven<=6:
amount_due = 27 * days_driven
elif days_driven >= 7 and days_driven <=27:
amount_due = 162 + ((days_driven-7)*25)
elif days_driven >=28 and days_driven <= 60:
amount_due = 662 + ((days_driven-28)*23)
print('amount due is $', amount_due)
break
elif code[0].lower() == "q":
print("You chose Quit!")
break
else:
print("You must choose between b,c,d and q")
continue
```

ADD COMMENT
EDIT

Please log in to add an answer.