Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; int main() { double a, b, c; //get values for a, b, c cout < < Enter a, b, c respectively:

#include  using namespace std; int main() { double a, b, c; //get values for a, b, c cout << "Enter a, b, c respectively: "; cin >> a >> b >> c; if (a == 0) { //first order equation cout << "This is a first order equation, solution = " << -c / b << endl; } else { double D = pow(b, 2) - 4 * a * c; if (D > 0) { double x1 = (-b + sqrt(D)) / (2 * a); double x2 = (-b - sqrt(D)) / (2 * a); cout << "The equation had two distinct solutions: X1 = " << x1 << " X2 = " << x2 << endl; } else if (D == 0) { double x = -b / (2 * a); cout << "There is one double solution: " << x << endl; } else { cout << "There is no real solutions "; } } return 0; }

Modify the code above to implement it using classes.

Your class should have three double private member variables and a method solve() that will

display the solutions to the equation.

thank you so much.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago