Could anyone create this program for me?

Im looking for someone to create the following windows console program for me.

The program would kind of be like a virtual graph and by entering two certain points on the graph (xxx, yyy), and then it would execute a distance formula; SqRoot( (x2-x1/2)2 + (y2-y1/2)2 )

and then print the distance into the console, allowing the option to enter another 2 coordinates to find another distance.

please email me if you can help me out :) cheezycorncakes@gmail.com
Thanks in advance! ~michael
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
    int x1 = 0;
    int y1 = 0;
    int x2 = 0;
    int y2 = 0;

    cout << "Enter X1 = ", cin >> x1;
    cout << "Enter Y1 = ", cin >> y1;
    cout << "Enter X2 = ", cin >> x2;
    cout << "Enter Y2 = ", cin >> y2;
    cout << "Distance From (" << x1 << ", " << y1 << ") to (" << x2 << ", " << y2 << ") = " << sqrt(pow((x2 - x1/2), 2) + pow((y2 - y1/2), 2)) << endl;
}
If your doing this to learn, great, if you just need the results

in Excel
=SQRT(((a2-a3)^2)+((b2-b3)^2))
You can write it using classes as for example class Point. This class will have method distance.
Thanks so much everyone, helped out a ton, I was working on this all last night, and I came close to what Santosh has, but it wasnt as compact and perfected, i was also having a lot of errors with the pow and sqrt, but now that i see how he did it, i wont have these errors in the future. Whatever you guys do with resolved threads, you can do with this one! :D
sqrt(pow((x2 - x1/2), 2) + pow((y2 - y1/2), 2))

Why are x1 and y1 divided by 2?
I guess this what OP wanted
 
cout << "Distance From (" << x1 << ", " << y1 << ") to (" << x2 << ", " << y2 << ") = " << sqrt(pow(((x2 - x1)/2), 2) + pow(((y2 - y1)/2), 2)) << endl;
Topic archived. No new replies allowed.