Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Due Monday, February 6 by soopm to canvas Seattle Seahawks, not make it to the S

ID: 3811851 • Letter: D

Question

Due Monday, February 6 by soopm to canvas Seattle Seahawks, not make it to the Super Bowl. The coaches have asked you to write ortunately, did in offseason When drawing up plays, it helps the players a program to help the players practice quarte and and coaches to know the distance between between the a program wide receivers, between the running and the various is to develop enter back Your task user will that will take two positions the distance between them. The yards long by sets of x, y, in 3-D space and determine field 100 53 1/3 yards and z coordi all are in The dimensions: wide. Therefore, you can assume the following ranges for each of the between 0.00 and 100.00 yards y: between ooo and 53.33 yards .the z: between o.00 and 10.00 yards" their calculations height is 10 yards, this is the highest point the Seahawks use in of the goal posts The distance formula in three dimensions is: V(x2-x1) O2 yi) Program Requirements: does, the user for inputs the point. 1. Greet the user and say what the program prompt to formula. a. Assume the user will always enter data with two digits after the decimal error b. the user enters a value that is out of range for any of the inputs, print an message to the screen and end the program without doing the calculation. to 2. You must make use of the pow and functions from the Komath library 3. calculate the distance. variable names (x,x1, etc. are not allowed). the Make sure to csc1230 style for all program output should contain 4. In addition to follow prompts, your formatting: the welcome message and information in the following screenshot, and use the same he coordinates for the second position he distanc 5. Notes on output: numerical output only (the greeting a. The example above shows how to format the and prompts asking for input are up to you). the output as close as possible to the b. You must use stream manipulators to format example above (pay special attention to how the columns line up). are c. The output should reflect the fact that the coordinates entered by the user within the ranges listed above, and will contain 2 digits after the decimal point. in d. The calculated distance should be printed with 3 digits after the decimal point as the example above.

Explanation / Answer

#include<iostream>

#include<math.h>

using namespace std;

double distanceCalc(double xvar1, double yvar1, double xvar2, double yvar2,double zvar1,double zvar2)

{

    double xvar = xvar1 - xvar2;

    double yvar = yvar1 - yvar2;

                double zvar = zvar1 - zvar2;

    double dist;

    dist = pow(xvar,2)+pow(yvar,2)+pow(zvar,2);           //calculating distance by euclidean formula

    dist = sqrt(dist);                  //sqrt is function in math.h

    return dist;

}

int main()

{

cout<<"Hi Usr!!Hope you are doing great. ";

cout<<"This program inputs the 3Dimension variables and compute the distance as Sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2) ";

    double xvar1, yvar1,zvar1,xvar2, yvar2,zvar2;

    double dist;

    cout<<"Enter x,y,z values of first position "<<endl;           //user input needed

    cin>>xvar1;

    cin>>yvar1;

    cin>>zvar1;

    cout<<"Enter x,y,z values of second coordinate "<<endl;

    cin>>xvar2;

    cin>>yvar2;

    cin>>zvar2;

                if (xvar1<0.00 ||xvar2>100.00)

{

   cout<<"please enter the x values with in the range -0.00 to 100.00 yards ";

}

else if(yvar1<0.00 || yvar2>53.33)

{

    cout<<"please enter the y values with in the range -0.00 to 53.00 yards ";

}

else if (zvar1<0.00 || zvar2>10.00 )

{

   cout<<"please enter the z values with in the range -0.00 to 10.00 yards ";

}

else

{

    dist = distanceCalc(xvar1, yvar1 , xvar2, yvar2,zvar1,zvar2);       //calling distanceCalculate formula

                }

                cout<<"The coordinates of the first postion : (yards) ";

                cout<<"                                   x : "<< xvar1<<" ";

                cout<<"                                   y : "<< yvar1<<" ";

                cout<<"                                   z : "<< zvar1<<" ";

                cout<<"The coordinates of the second postion : (yards) ";

                cout<<"                                   x : "<< xvar2<<" ";

                cout<<"                                   y : "<< yvar2<<" ";

                cout<<"                                   z : "<< zvar2<<" ";

    cout<<"Distance Between the two positions is :"<<dist <<"yards";

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote