Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main (){
- srand(time(NULL)); //Need this for rand #'s
- int rad;
- double bor;
- rad=(-1)*((rand()%11)+5);
- bor=(-1)*(rand()%(-1*rad));
- double x,y;
- double xint;
- double overhead;
- double launch;
- double crater;
- double a,h,k;
- a=(-1)*((rand()%31)+20);
- h=((rand()%31)-20);
- k=(rand()&15)+5;
- if (h == 0) {
- h = h + .1;
- }
- cout << "GIVEN VALUES " << endl;
- cout<<"Radar range is "<<rad<<endl;
- cout<<"Our border is at "<<bor<<endl;
- cout<<"a= "<<a<<endl;
- cout<<"h= "<<h<<endl;
- cout<<"k= "<<k<<endl;
- //y=((1/a)*(pow((x-h),2)+k));
- overhead = ((1/a)*(pow(h,2))+k);
- xint=sqrt((-1*k)*(a));
- launch=(-1*xint)+k;
- //overhead is y int
- double a1;
- a1 = 1/a;
- crater=(xint)+k;
- if ( h > 0) {
- cout <<setprecision (2) << "The equation of the rocket in vertex form is y = " << a1 << "(x-" << h << ")^2 + " << k << endl;
- }
- if (h < 0) {
- h = h * -1;
- cout <<setprecision (2) << "The equation of the rocket in vertex form is y = " << a1 << "(x+" << h << ")^2 + " << k << endl;
- h = h * -1;
- }
- double b ,c;
- b = -((2*h)/a);
- c = ((h*h)/a) + k;
- cout << setprecision (2) << "The equation of the rocket in standard form is y = (" <<a1<< ")x^2 + " << b << "x + " << c << endl << endl << endl;
- x = 1;
- double p1, p2, p3, p4;
- double n[3];
- cout << "CALCULATED VALUES" << endl ;
- cout << "We have observed the following points that the rocket has passed through: ";
- cout << endl << "The first point is (0," << c << ")" ;
- for (int i = 0;i<3;i++)
- {
- y=((1/a)*(pow(x,2)))+(b*x)+c;
- cout << setprecision(2) << endl << "Another point is (" << x << "," << y <<")";
- x = x+2;
- n[i] = y;
- }
- double m[3] = {1 , 3, 0};
- double temp1, temp2, num, den;
- temp1 = (n[1]-c);
- temp2 = (m[1]*m[1])*(n[0]-c);
- num = temp1 - temp2;
- den = (-(m[1]*m[1])+m[1]);
- b = num/den;
- a = (n[0] - c) - b;
- cout << endl << "a = " << a << endl;
- cout << "b = " << b <<endl;
- cout << "c = " << c <<endl;
- cout <<setprecision (2) << "The equation of the rocket in standard form is y = (" << a << ")x^2 + " << b << "x + " << c << endl;
- h = -(b)/ (2*a);
- k = (a*h*h) + (b*h) + c;
- if ( h > 0) {
- cout <<setprecision (2) << "The equation of the rocket in vertex form is y = " << a << "(x-" << h << ")^2 + " << k << endl;
- }
- if (h < 0) {
- h = h * -1;
- cout <<setprecision (2) << "The equation of the rocket in vertex form is y = " << a << "(x+" << h << ")^2 + " << k << endl;
- }
- if (h == 0)
- {
- cout << endl << "The missle interception has failed. Take cover. ";
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement