Project on QUADRATIC FUNCTIONS

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:
  1. 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.

  2. 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>.

  3. 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:
  1. f(x) = 0 x2 + 0 x + 0
  2. f(x) = 0 x2 + 0 x + 1
  3. f(x) = 0 x2 + 2 x + 0
  4. f(x) = 0 x2 + 3 x + 4
  5. f(x) = 5 x2 + 0 x + 0
  6. f(x) = 6 x2 + 0 x + 7
  7. f(x) = 8 x2 + 9 x + 0
  8. f(x) = 10 x2 + 11 x + 12
  9. 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.

© 1998-08-31 cpsm ; last update 2003-11-03