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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string para_mxb;
float m_1, b_1, y_1, x_1, mx;
float m_2, b_2, y_2, x_2;
float m, b, y, x;
float y2, y1, x2, x1;
float ap, bp, cp, yp, xp;
string beganswer, beganswer_2;
beg:
cout << "What kind of coordinates would you like to find? "
<< "Type in 'linear' for y=mx+b" << endl << "type in 'parabola' for ax²+bx+c: ";
cin >> para_mxb;
if (para_mxb == "parabola" || para_mxb == "Parabola")
{
cout << "What would you like to do? "
<< "To find coordinates type in 'coord'" << endl;
cin >> beganswer_2;
if (beganswer_2 == "coord" || beganswer_2 == "Coord")
{
cout << "Please type in a: " << endl;
cin >> ap;
cout << "Please type in b: " << endl;
cin >> bp;
cout << "Please type in c: " << endl;
cin >> cp;
for (xp=-10;xp<11;xp++)
{
yp = ap*(xp*xp) + bp * xp + cp;
cout << "(" << xp << ", " << yp << ")" << endl;
}
}
}
else if (para_mxb == "linear")
{
cout << "What would you like to do?"
<< endl << "To find a slope type in 'slope'" << endl
<< "To find coordinates type in 'coord'" << endl
<< "To find y intercept type in 'inter'" << endl
<< "To find x intercept type in 'xinter'" << endl;
cin >> beganswer;
if (beganswer == "slope" || beganswer == "Slope")
{
cout << "Enter y2: ";
cin >> y2;
cout << "Enter y1: ";
cin >> y1;
cout << "Enter x2: ";
cin >> x2;
cout << "Enter x1: ";
cin >> x1;
cout << "Slope is " << (y2-y1) << " / " << (x2-x1) << " or " << (y2-y1)/(x2-x1) << endl;
system("pause");
goto beg;
}
else if (beganswer == "coord" || beganswer == "Coord")
{
cout << "Enter m: ";
cin >> m;
cout << "Enter b: ";
cin >> b;
for (x=-10;x<11;x++)
{
y = (m*x) + b;
cout << "(" << x << ", " << y << ")" << endl;
}
system("pause");
goto beg;
}
else if (beganswer == "inter" || beganswer == "Inter")
{
cout << "Enter y: ";
cin >> y_1;
cout << "Enter x: ";
cin >> x_1;
cout << "Enter slope: ";
cin >> m_1;
mx = m_1 * x_1;
b_1 = y_1 - mx;
cout << "The y intercept is " << b_1 << endl;
system("pause");
goto beg;
}
else if (beganswer == "xinter" || beganswer == "Xinter")
{
cout << "Enter m: " << endl;
cin >> m_2;
cout << "Enter b: " << endl;
cin >> b_2;
mx = b_2/ m_2;
if (mx<0)
{
cout << mx << endl;
system("pause");
goto beg;
}
else if (mx>0)
{
cout << "-" << mx << endl;
system("pause");
goto beg;
}
else if (mx == 0)
{
cout << mx << endl;
system("pause");
goto beg;
}
}
}
system("pause");
goto beg;
return 0;
}
|