


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CSC 145 - Laboratory Exercise 4: Problem Solving with a Computer The development of a computer program to solve a problem can be divided into a number of clearly defined tasks. In this exercise you will be guided through these tasks as you develop a computer program to find the roots of a quadratic equation. Preparation : This activity is to be completed before entering the laboratory. Use the textbook and lecture notes to answer the questions below. The quadratic formula gives the value(s) of x which solve expressions of the form ax bx c 2 0 1 where a,b and c are constants. The quadratic formula is given by, x b b ac a 2 4 2
When the radical (square-root term) is zero, there is one real value of x (called the root) which will solve the quadratic equation. When the radical is positive there are two real roots and when the radical is negative there are no real roots for the quadratic expression. Use an example to show that expression 2 gives the root(s) to a quadratic equation. Example quadratic equation a = ___________________ b = _____________________ c = ___________________ Solve for x x b b ac a 2 4 2 x b b ac a 2 4 2 Develop an Ada program that accepts the values of the three coefficients a, b and c of a quadratic equation of the form given by Eq.1. Your program should compute the root(s) of this expression, if any, and display them with an appropriate message.
Define the Problem - The first step in program development is to gain a clear understanding of the problem being solved.
If the factors are the same there is only one root, and if the expression cannot be factored there are no real roots. Generate three test cases (sample quadratic equations) for your program which will illustrate each of the three possible cases. Two Roots One Root No Real Roots Design an Algorithm - The next step in software development is the functional decomposition of the problem. In this case it is sufficient to define the input , process and output operations.
b. executable program? __________________________________________________________