Question

I he following formula gives the distance between two points (x1, yl) and (02, y2) in the Cartesian plane The main0 function is provided. You should implement the following functions: sqrt [ (x2-x1), (y2-yl) 1. Fi ndRadius... ): This function takes as its parameter four numbers that represent the center and a point on the circle, finds and returns the circles radius. 2 CircleCalculations(....: This function takes as its parameter a number that represents the radius of the circle and returns the circles circumference (if r is the radius, the circumference is 2 Pir) and returns the circles area Gfr is the radius, the area is Pi r?.). Assume that Pi 3.1416. 3. PrintCircle(.) to print the circle informations as shown in the sample (Bonus: format your results to two decimal points): int main () float xPoint yPoint xCenter, yCenter, radius area , circunference: cout<<Enter the x and y coordinates of a point on the airalo: cin>xPoint>>yPoint; cin>>xCenter>>yCenter; radius FindRadius (xPoint,yPoint, xCenter, yCenter) : CircleCalculations (radius,circumference,area) PrintCircle (radius,circumference,area) the x and y coordinates of the center of the circle return o; Sample input/output Enter the x and y coordinates of a point on the circle7.4 6 Enter the x and y coordinates of the center of the circle 2.1 3.3 The radius of the circle 5.95 The circumference of the circle 37.37 The area of the circle 111.15
0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
#define Pi 3.1416

float FindRadius(float xPoint, float yPoint, float xCenter, float yCenter)
{
return sqrt(pow((xCenter-xPoint),2) + pow((yCenter-yPoint),2));
}

void CircleCalculations(float radius, float *circumference, float *area)
{
*circumference = 2*Pi*radius; //passing result by reference
*area = Pi*radius*radius;
}

void PrintCircle(float radius, float circumference, float area)
{
std::cout << std::fixed;
std::cout << std::setprecision(2); //setting result to 2 decimal places

code: #include<iostream> #include<iomanip> #include-math.h> using namespace std; #define Pi 3.1416 float FindRadius(float xPoint, float yPoint, float xCenter, float yCenter) return sqrt(pow(xCenter-xPoint),2) pow((yCenter-yPoint),2); void CircleCalculations(float radius, float circumference, float *area) *circumference = 2*Pi*tadius; //pass.ng result by reference *a rea = Pi*radius*radius void PrintCircle(float radius, float circumference, float area) std:cout<<std:fixed; std::cout < std:setprecision(2); I/setting result to 2 decimal places coutくくendl<<endl cout<<The radius of the circle <<radius<<endl cout<<The circumference of the circle-<<circumference<<endl cout<<The area of the circle-<<area-«endl int main( float xPoint, yPoint, xCenter, yCenter, radius, area, circumference; cout<<Enter the x and y coordinates of a point on the \circle\: . cin>>xPoint>yPoint cout«<Enter the x and y coordinates of the \center\ of the circle : ; cin>>xCenter>>yCenter; radius FindRadius(xPoint, yPoint, xCenter, yCenter); CircleCalculations(radius, &circumference, &area); /calculate area and circumference

Add a comment
Know the answer?
Add Answer to:
I he following formula gives the distance between two points (x1, yl) and (02, y2) in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using separate files, write the definition for a class called Point and a class called Circle. Th...

    Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...

  • Complete the following coding in java Create a class Circle that represents a round moving dot....

    Complete the following coding in java Create a class Circle that represents a round moving dot. A circle object needs to contain double variables to store the: Current X location of the circle's center Current Y location of the circle's center Radius of the circle Direction of the circle's movement in radians Speed of the circle's movement . . The Circle class must contain a constructor Circle double x, double y, double radius) that initializes the circles center x, y...

  • I need help with C, please don't copy other answers!! Thanks Declare a structure to represent...

    I need help with C, please don't copy other answers!! Thanks Declare a structure to represent a circle. Each circle stores information about the center and the radius. Center is represents with x and y coordinates. Both center and radius uses doubles. Allocate an array of 502 circle pointers and dynamically allocated memory to store a circle pointed by each array entry. Randomly generate circles using the following function. double rand_ float (double a, double b) {return ((double) rand()/RAND_MAX) *...

  • U8ing separate files, write th definition for a clas called Poit and a class called Cirele...

    U8ing separate files, write th definition for a clas called Poit and a class called Cirele 1. The class point has the data members (double) and y (double) for the x and y coordinates The class has the following ember functions a) void set x (double) to set the x data member b) void set y(double) to set the y data member c) double get-x() to return th the data member d) double get yO to zeturn the the y...

  • Question 11 (20 points) Given the class Point below, define a class Circle that represent a...

    Question 11 (20 points) Given the class Point below, define a class Circle that represent a circle with a given center and radius. The circle class should have a center attribute named center as well as a floating point radius attribute. The center is a point object, defined by the class Point. The class should also have these members: the constructor of the class, which should take parameters to initialize all attributes - a getter for center a setter for...

  • Three geometric entities (a circle, a rectangle and a triangle) should be first randomized using rand...

    Three geometric entities (a circle, a rectangle and a triangle) should be first randomized using rand function in line with srand(time(NULL)). These three geometrric entities can/should be represented using the following C struct samples in your program: Write three functions for each geometric entity that randomizes the geometric parameters (such as center X and Y coordinates and radius for a circle) and returns these geometries (such as struct Circle, struct Rectangle and struct Triangle). Note that floating numbers should be...

  • I need to implement a program that requests a x,y point and the radius of a...

    I need to implement a program that requests a x,y point and the radius of a circle. then it figures out the area and circumference using an overloaded operation. The full instructions, what I have and the errors I have are below. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT