Made it a little shorter... HOWEVER. Now when entering these test values:

(x1,y1) = 2.0 5.6

(x2,y2) = 3.1 -4.7

(x3,y3) = -2.2 3.5

it's giving me the answers 3.76, 3.76, and 6.53. It's supposed to be 3.76, 4.26, and 6.53 instead. I've tried messing around with brackets and other parts of the code... but I can't seem the catch the error.. Any suggestions?

Code:

#include <stdio.h>
#include <math.h>
int main()
{
double x1, y1, x2, y2, x3, y3;
printf("What are the x-y coordinates of the first location?\n");
scanf("%lf%lf", &x1, &y1);
printf("What are the x-y coordinates of the second location?\n");
scanf("%lf%lf", &x2, &y2);
printf("What are the x-y coordinates of the third location?\n");
scanf("%lf%lf", &x3, &y3);
double centroid_x = (x1+x2+x3)/3; //Calculates the x-coordinate of the centroid of the triangle.
double centroid_y = (y1+y2+y3)/3; //Calculates the y-coordinate of the centroid of the triangle.
double distance_1 = sqrt(pow(x1-centroid_x,2)+pow(y1-centroid_y,2)); //Calculates the distance from the centroid to point (x1,y1).
double distance_2 = sqrt(pow(x2-centroid_x,2)+pow(y2-centroid_y,2)); //Calculates the distance from the centroid to point (x2,y2).
double distance_3 = sqrt(pow(x3-centroid_x,2)+pow(y3-centroid_y,2)); //Calculates the distance from the centroid to point (x3,y3).
printf("You should live at location (%.2lf, %.2lf).\n", centroid_x, centroid_y);
double smallest, middle, largest;
if(distance_1 < distance_2 && distance_1 < distance_3)
{ smallest = distance_1; }
if(distance_2 < distance_3)
{ middle = distance_2;
largest = distance_3; }
else
{ middle = distance_3;
largest = distance_2; }
{ if(distance_2 < distance_1 && distance_2 < distance_3)
smallest = distance_2;
else
smallest = distance_3; }
printf("The corresponding travel distances are: %.2lf, %.2lf, and %.2lf.\n", smallest, middle, largest);
return 0;
}