1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include<iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void getIntegers(string, double&);
double quadEquation(double, double, double, double);
double inputValidate(double);
double getDiscriminant(double, double, double);
int main()
{
double discriminant,squared, squareRoot;
getDiscriminant(discriminant,squared, squareRoot);
return 0;
}
void getIntegers(string prompt, double& user_input)
{
cout << prompt;
user_input = inputValidate(user_input);
}
double quadEquation(double num1 , double num2, double num3, double findX)
{
return 0.0;
}
double inputValidate(double num1)
{
while (!(cin >> num1))
{
cout << "Error. Number must not be a letter "
<< ", it must be a number:";
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return num1;
}
double getDiscriminant(double userNum1, double userNum2, double userNum3)
{
double userNum1, userNum2, userNum3, findX, numInt = 1;
//getIntegers("Enter Intergers", numInt);
for (int i = 0; i < numInt; i++)
{
getIntegers("Enter integer a: ", userNum1);
getIntegers("Enter integer b: ", userNum2);
getIntegers("Enter integer c: ", userNum3);
}
double a = userNum1, b = userNum2, c = userNum3,
discriminant, squared, squareRoot;
discriminant = b * b - (4 * a * c);
squared = pow(userNum2, 2);
squareRoot = sqrt(b);
std::cout.precision(2);
std::cout.setf(std::ios::fixed);
cout << "This is the discriminant: " << discriminant << endl;
cout << "B Squared: " << squared << endl;
cout << "Squared Root of b: " << squareRoot << endl;
return discriminant,squared,squareRoot;
}
| |