Question: C++ Problem 1) Using the pseudo code and block diagram from class notes write a program that finds real solutions of a quadratic equation The

C++

Problem 1)

Using the pseudo code and block diagram from class notes write a program that finds real solutions of a quadratic equation

The program should solve a quadratic equation using numerical values of the coefficients a, b, and c. The values of the coefficients have to be inputted by user from keyboard.

The program should produce the real solutions of the quadratic equation, x1 and x2, or give an error message if the real solutions do not exist. Program should print the equation on the screen, real solutions x1 and x2, if they exist, or an error message.

Tip: this assignment requires using mathematical functions, so you need to include header file.

Problem 2)

Modify program from problem 1 such that it can produce real and complex solutions of quadratic equation.(25 points)

Tip: C++ does not provide a special type for complex numbers, but you could use 4 double variables x1Real, x2Real, x1Imaginary, x2Imaginary. The first two variables will store the real part of the solution, and the other two imaginary part. You could output the solution using this code:

cout << X1 = << x1Real << + << x1Imaginary <

cout << X2 = << x2Real << + << x2Imaginary <

Note: Since, in the case of a complex solution, discriminant is negative you need to multiply it by -1.0 before taking the square root from it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!