| Course: |
CSE 103 |
| Project Number: |
1 |
| NSD Due Date: |
(no NSD due; see
NSD)
|
| Project Due Date: |
(see the calendar on Angel) |
| Project Filename: |
a:quadratc.bpr |
| Program Filename: |
a:quadratc.cpp |
| Output Filename: |
a:quadratc.txt |
| Project Objective: |
To write a first program that solves a mathematical problem. |
| Problem: |
- Write a C++ program that will prompt the user for at least one
polynomial that is at most a
quadratic function, i.e.
f(x) = a x2 + b x + c
and find all its
roots using
the quadratic formula
x = [b ± (b2 4ac)½] / (2a)
whenever appropriate.
- Use the pre-defined C++ function sqrt which evaluates
the square root of a real number of data type double
e.g.: d = sqrt (disc)
where disc is the discriminant of a quadratic
function. You will need the header file
#include <math.h>.
- Recall that a complex number has the form
a + bi
where a is the real part, b is the
imaginary part, and
i = (1)½
|
| Input: |
Enter the following data interactively:
- f(x) = 0 x2 + 0 x + 0
- f(x) = 0 x2 + 0 x + 1
- f(x) = 0 x2 + 2 x + 0
- f(x) = 0 x2 + 3 x + 4
- f(x) = 5 x2 + 0 x + 0
- f(x) = 6 x2 + 0 x + 7
- f(x) = 8 x2 + 9 x + 0
- f(x) = 10 x2 + 11 x + 12
- f(x) = 1.92 x2 8.37 x + 4.65
|
| Output: |
Do not forget to include a heading with each new page.
Print no more than five functions and their corresponding solutions to a page
centered horizontally and vertically.
|
| Reminder: |
Follow
General Instructions for Programming
and the
Basic Formatting Guidelines.
|