//**************************************
// Name: calculates the quadratic equation
// Description:This program calculates the quadratic equation
// By: Wilton Marranzini
//
//
// Inputs:A, B and C
//
// Returns:the answer of the quadratic equation
//
//Assumes:None
//
//Side Effects:none
//
//Warranty:
//Code provided by Planet Source Code(tm) (http://www.Planet-Source-Code.com) 'as is', without warranties as to performance, fitness, merchantability,and any other warranty (whether expressed or implied).
//Terms of Agreement:
//By using this source code, you agree to the following terms...
// 1) You may use this source code in personal projects and may compile it into an .exe/.dll/.ocx and distribute it in binary format freely and with no charge.
// 2) You MAY NOT redistribute this source code (for example to a web site) without written permission from the original author.Failure to do so is a violation of copyright laws.
// 3) You may link to this code from another website, provided it is not wrapped in a frame.
// 4) The author of this code may have retained certain additional copyright rights.If so, this is indicated in the author's description.
//**************************************
//Author: Wilton Marranzini
//This program calculates the quadratic equation
#include
#include
void cal_root (float a, float b, float c, float & answer1, float & answer2);
void main()
{
float num_a;
float num_b;
float num_c;
float answer1;
float answer2;
char repeat = 'y';
while ((repeat == 'y')||(repeat == 'Y'))
{
cout<< "Enter the value for A\n";
cin>> num_a;
cout<< "Enter the value for B\n";
cin>> num_b;
cout<< "Enter the value for C\n";
cin>> num_c;
cal_root(num_a, num_b, num_c, answer1, answer2);
cout<< "Would you like to do another quadratic equation. (Y- yes N- no)\n";
cin>>repeat;
}
}
void cal_root (float a, float b, float c, float & answer1, float & answer2)
{
float check;
check = (pow(b,2))- 4 * a * c;
if (check < 0 )
{
cout<< "The roots are complex and cannot be solved by this program yet!\n";
}
if (check == 0)
{
cout<< "The roots are both the same and are equal to -b/2a.\n";
answer1 = -b/(2*a);
answer2 = answer1;
cout<< answer1 < 0)
{
cout<< "Is positive there are two unequal, real roots.\n";
answer1 = (-b + sqrt(pow(b,2)-4*a*c))/(2*a);
answer2 = (-b - sqrt(pow(b,2)-4*a*c))/(2*a);
cout<< answer1 <