Need help with a simple C++ assignment

Need help with a simple C++ assignment

The program below solves the Quadratic formula for real roots only, but it does not use C++ classes.  Please re-design and re-implement the program so that it uses C++ classes.

PLEASE ONLY GIVE ME THE SOURCE CODE, I DO NOT WANT A CPP FILE. Also I will run the program to make sure it works. Thank you so much!!

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;

int main () {
  double a, b, c, disc = 0;
  cout << “Please enter your three coefficients for your quadratic equation “;
  cin >> a >> b >> c;
  if (!cin.eof() && cin.good() && a != 0) {
   
  // system keyboard tests !cin.eof() and cin.good
  // test for eof from the keyboard and good input data in that order.  The !cin.eof()
  // test has to come first to check if the user wants to bail without completing his
  // data entry. If the test cin.good is put first, the control-z or control-b input
  // will be understood as an invalid input, which is an undesirable side-effect.
  // a != 0 is an application test which rejects a value which equals zero
  // application tests always follow system tests and never precede them.
   
  disc = b*b – 4*a*c;
  if (disc < 0)
  { cout << ” No real roots”; }
  else if (disc == 0)
  { double root = -b/(2*a);
   if (root == 0) root = abs(root);
   cout << ” One real root; x = ” << root;
  }
  else
  { // show both roots
   double root1, root2;
   root1 = -b/(2*a) + sqrt (disc)/(2*a);
   root2 = -b/(2*a) – sqrt (disc)/(2*a);
   cout << ” Two real roots; root1 = ” << root1
    << ” and root2 = ” << root2;
  }
  }
  else
  if (!cin.eof())
  cout << ” One or more invalid inputs”;
  cout << endl;
  return EXIT_SUCCESS;
}

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper