go to previous page   go to home page   go to next page

Answer:

A sentinel loop looks like the best choice.


Sentinel Loop

There are various ways to do this. One way is to have the user hit "enter" to continue after each set of roots has been printed, and "q" followed by "enter" to quit. User interaction will look something like this:

Enter a b c: 1 -2 -15
Two solutions: x = 5.000000 and x = -3.000000
Hit enter to continue, q enter to quit:

Enter a b c: 1.0 0.0 -6.25
Two solutions: x = 2.500000 and x = -2.500000
Hit enter to continue, q enter to quit:

Enter a b c: 0 4 5
Coefficient a must not be zero
Hit enter to continue, q enter to quit:

Enter a b c: 1.5 9.375 2.75
Two solutions: x = -0.308568 and x = -5.941432
Hit enter to continue, q enter to quit:

Enter a b c: 2 1 1
No real roots
Hit enter to continue, q enter to quit: q

Bye!

QUESTION 4:

Does the universal flow chart apply to this program?