Engineering
02.08.2022 16:13
225
500
9
Solved by an expert

Write a modular program that finds the equation, area, and circumference of a circle,

Write a modular program that finds the equation, area, and circumference of a circle, given the coordinates of the center of the circle and coordinates of a point on the circle which are entered by the user. Given the coordinates of the center of a circle (Cx, Cy) and the coordinates of a point on the circle (Px, Py) we can find the radius of the circle using the following formula: r= J(Cx - Px)2 + (Cy – Py)? The equation of the circle with radius r and center (Cx, Cy) is: (x – Cx)2 + (y – Cy)2 = y2 Calculate the value of a constant PI (TT) as follows: n = acos(-1) Your program must utilize at least four meaningful called functions that you define. One of the functions will get the coordinates of the center of the circle and the coordinates of a point on the circle and place them in variables defined in main by reference. Also you must use functions to calculate and return the area and circumference of a circle. These functions must be prototyped as follows (you may include the parameter name, but the argument and return type must not be changed): double findArea (double); double findCircum (double); Please note, the final versions of findArea and findCircum do NOT print anything. Don't forget that the definitions of functions (not the prototypes, the definitions) must be preceded by a comment that describes what the function does, the arguments or other inputs it gets (from the user) and the value it returns (if any) or other outputs it produces (displays on the screen). Sample output of a program that satisfies the requirements is shown below. Try to make your output look as much like this as possible. The default precision was used in the sample. The data entered by the user is in blue. Sample Output 1: Enter the x and y coordinates of the center of the circle separated by a comma: 2,5 Enter the x and y coordinates of a point on the circle separated by a comma: 6,2 A circle centered at (2, 5) passing through a point (6, 2) has the equation: (x - 2)^2 + (y – 5)^2 = 25 The circle has an area of 78.5398 square units. The circle has a circumference of 31.4159 units.
Show Answers
isyssjones42
isyssjones42
4,9(44 marks)

Explanation:

#include <bits/stdc++.h>

#include <iostream>

#include <string>

#include <cmath>

using namespace std;

//this function reads the cooridnates of Center from the user

//parameteres are pointer variables of Cx,Cy

//it does not return anything and stores coordinates at given addresses of Cx,Cy

void readCenter(int *Cx,int *Cy)

{

string cooridnates;

cout << "Enter the x and y cooridnates of the centre of the circle separated by comma: " ;

getline(cin,cooridnates);//reading inputs

//convering string ot integer

string x = cooridnates.substr(0, cooridnates.find(","));

string y = cooridnates.substr(cooridnates.find(",")+1);

*Cx=stoi(x);

*Cy=stoi(y);

}

//this function reads the cooridnates of Point from the user

//parameteres are pointer variables of Px,Py

//it does not return anything and stores coordinates at given addresses of Px,Py

void readPoint(int *Px,int *Py)

{

string cooridnates;

cout << "Enter the x and y cooridnates of a point on the circle separated by comma: " ;

getline(cin,cooridnates);//reading inputs

//convering string ot integer

string x = cooridnates.substr(0, cooridnates.find(","));

string y = cooridnates.substr(cooridnates.find(",")+1);

*Px=stoi(x);

*Py=stoi(y);

}

double findArea(double radius)

{

double pi=acos(-1);

return pi*pow(radius,2);

}

double findCircum(double radius)

{

double pi=acos(-1);

return 2*pi*radius;

}

int main()

{

int Cx,Cy;

int Px,Py;

readCenter(&Px,&Py);

readPoint(&Cx,&Cy);

double radius=sqrt(pow((Px-Cx),2)+pow((Py-Cy),2));

cout<<"The circle has an area of "<<findArea(radius)<<" sqaure units\n";

cout<<"The circle has a Circumference of "<<findCircum(radius)<<" units";

return 0;

}

BreBreDoeCCx
BreBreDoeCCx
4,5(93 marks)
As noted earlier, in sediments, or in any porous system, the presence of solid particles causes the diffusion paths of species to deviate from straight lines. Consequently, the diffusion coefficients of species must be corrected for the tortuosity.

Popular Questions about the subject: Engineering

State two (3) class of fire and list two (2) material that are found...
Engineering
03.01.2022 11:37
Mr. Jones is preparing himself to cut a poin piece of Hot Meal on anvil...
Engineering
06.08.2021 10:22
Which is a common refrigerant for domestic air conditioners?...
Engineering
30.08.2022 09:22

New questions by subject

Acids and bases are found everywhere they are used to make things such...
Chemistry
01.11.2020 02:05
What is the force that keeps the Balanced Rock balancing on its tiny...
Chemistry
01.04.2020 15:24
What is the result of subtracting the second equation from the first?...
Mathematics
08.09.2022 17:03
#
#
#
#
# #

We expand our knowledge with many expert answers