A crcle can be specified by giving the coordinates of itscenter,and coordnates o
ID: 3618081 • Letter: A
Question
A crcle can be specified by giving the coordinates of itscenter,and coordnates of apoint on its circumference. Fr each pairof the points specifying a circle, the program will compute isradius, diameter, cicumference and area. Use a dferent function foreach computation. input will be from a file. Each line of the input file hasfour floating point values, representing in left-to-right order,the x-coordinate of the center, the y-coordnat of the center, thex-coordinate o the point on the circle and the y-coordinate of thepoint on the circle. The numbr of lines in an input file will vry.Sample input data could b: 0.0 0.0 3.1 2.8 5.5 0.0 5.5 3.0 4.0 2.5 0.0 2.5 -1.0 2.75 -4.5 6.75 So, each line of input represents a cicle, and program is tooutput, to a file, the center point, the point on thecircumference, the radius, the diameter, te crcumfrence and heareaof the circle. Formulas: if r represents the radius of the circe, then hecrcumference is 2(pi)r,and the area is (pi)r^2. You may use 3.1416for pi. A crcle can be specified by giving the coordinates of itscenter,and coordnates of apoint on its circumference. Fr each pairof the points specifying a circle, the program will compute isradius, diameter, cicumference and area. Use a dferent function foreach computation. input will be from a file. Each line of the input file hasfour floating point values, representing in left-to-right order,the x-coordinate of the center, the y-coordnat of the center, thex-coordinate o the point on the circle and the y-coordinate of thepoint on the circle. The numbr of lines in an input file will vry.Sample input data could b: 0.0 0.0 3.1 2.8 5.5 0.0 5.5 3.0 4.0 2.5 0.0 2.5 -1.0 2.75 -4.5 6.75 So, each line of input represents a cicle, and program is tooutput, to a file, the center point, the point on thecircumference, the radius, the diameter, te crcumfrence and heareaof the circle. Formulas: if r represents the radius of the circe, then hecrcumference is 2(pi)r,and the area is (pi)r^2. You may use 3.1416for pi.Explanation / Answer
please rate - thanks #include #include #include using namespace std; double diameter(double); double radius(double,double,double,double ); double circum(double ); double area(double ); int main() {double x1,y1,x2,y2; double rad,diam,circ,areaa; ifstream in; ofstream out; in.open("input.txt"); //open file if(in.fail()) //is it ok? { coutx1; while(in) {in>>y1>>x2>>y2; rad=radius(x1,y1,x2,y2); diam=2*rad; circ=circum(rad); areaa=area(rad); outRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.