input center and a point on a circle a million times with no correct output

I think I may be dumb or missing something. I have attempted way to many times to get this program to output correctly and I just can't seem to do it.

This is the exercise that I am currently facing:

The following formula gives the distance between two points, (x₁,y₁) and (x₂,y₂) in the Cartesian plane:

\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}(x2​−x1​)2+(y2​−y1​)2​

Given the center and a point on the circle, you can use this formula to find the radius of the circle.

Instructions

Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s radius, diameter, circumference, and area. Your program must have at least the following functions:

- distance: This function takes as its parameters four numbers that represent two points in the plane and returns the distance between them.
- radius: This function takes as its parameters four numbers that represent the center and a point on the circle, calls the function distance to find the radius of the circle, and returns the circle’s radius.
- circumference: This function takes as its parameter a number that represents the radius of the circle and returns the circle’s circumference. (If r is the radius, the circumference is 2πr.)
- area: This function takes as its parameter a number that represents the radius of the circle and returns the circle’s area. (If r is the radius, the area is πr².) Assume that π = 3.1416.
- Format your output with setprecision(2) to ensure the proper number of decimals for testing!



And this is what I have but it keeps coming up wrong:

//************************************************************
// Author: 
//
// Programming Exercise 6-11
// A program that asks the user to enter the center and a point on the circle and the outputs the the circle's:
  // -Diameter
  // -Radius
  // -Circumference
  // -Area
//*************************************************************

// Define the Header Files 
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

// Declaring the Constant Double
const double PI = 3.1416;

// Values

  // Declaring the Function Prototypes
double distance(double,double,double,double);
double radius(double,double,double,double);
double circumference(double);
double area(double);
void getPoint(double&,double&);

int main() 
{
     // Write your main here

  // Declare the Variables 
double x1;
double y1;
double x2;
double y2;
double r;

  // Prompt the user to enter the center on the circle
cout << fixed << showpoint << setprecision(2);
cout << "Enter the Center coordinates for your circle\n";
getPoint(x1,y1);
cout <<"Enter the coordinates for a point located on your circle\n";
getPoint(x2,y2);

  //Declaring a method to find the radius
r = radius(x1,y1,x2,y2);

  // Outputting the results found
cout << "Radius = " << r << std::endl;
cout << "Diameter = " << 2*r << std::endl;
cout << "Circumference = " << circumference(r) << std::endl;
cout << "Area = " << area(r) << std::endl;

  system("pause");
    return 0;
}

// Defining the Functions for the program

  //Distance Function
double distance(double x1,double y1, double x2, double y2)
{
  return sqrt(pow(x1-x2,2))+pow(y1-y2,2);
}

  // Radius Function
double radius(double x1,double y1,double x2, double y2)
{
  return distance(x1,y1,x2,y2);
}

  // Circumference Function
double circumference(double r)
{
  return 2 * PI * r; 
}

  //Area Function
double area(double r)
{
  return PI * pow(r,2);
}

void getPoint(double& x, double& y)
{
  cout << "x: ";
  cin >> x;
  cout << "y: ";
  cin >> y;
}
 
return sqrt(pow(x1-x2,2))+pow(y1-y2,2);


The closing bracket for the sqrt is in the wrong place

 
return sqrt(pow(x1-x2,2)+pow(y1-y2,2));

... Oh, wow. Thank you. I can't believe I missed that.
Topic archived. No new replies allowed.