I need help to finish this program: Write a program to move and caluclate the ar
ID: 3619999 • Letter: I
Question
I need help to finish this program:Write a program to move and caluclate the area and circumference of a circle.
The program should read from the screen the information of a circle, which contains:
1. the location of a circle indicated by three integers, i.e.
x- and y-coordinates of the center, and radius.
2. an integer indicating the moving distance in the horizontal direction.
Positive number means moving right, otherwise moving left.
3. an integer indicating the moving distance in the vertical direction.
Positive number means moving down, otherwise moving up.
For example, suppose we read the following 5 intergers from the screen:
20 10 40 9 -7
So the location of the center is (20, 10), and radius is 40. The circle should be moved 9 units
to the right and 7 units up.
You are required to declare and define the following "void" functions,
1. moveCircle function, which passes coordinates of the center by reference, and the
moving distances on horizontal and vertical directions by value.
2. calculate function, which passes the radius by value, and get back the area
(PI*radius*radius) and circumference (2*PI*radius) of the circle through reference
parameters. Assume PI = 3.14 within this function.
*/
#include
#include
#include
using namespace std;
// Function prototypes
moveCircle function: a void function that passes coordinates of the center by
reference, and the moving distances on horizontal and vertical directions by value.
calculate function: a void function that passes the radius by value, and get
back the area (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference parameters. Assume PI = 3.14 within this function.
int main( )
{
int x; //x-coordinate of the center
int y; //y-coordinate of the center
int radius; // the radius of the center
int hdist; // moving distance on horizontal direction
int vdist; // moving distance on vertical direction
double area; // area of the circle
double circumference; // circumference of the circle
cin >> x >> y >> radius >> hdist >> vdist; //Read the circle information
// Calculate the new x,y cordinates by calling the moveCircle function
// Calculate the area and the circumference of the circle by calling the calculate function
cout << " Center = (" < << " Area = " << area << " Circumference=" << circumference << endl;
return 0;
}
// moveCircle function: a void function that passes coordinates of the center by reference,
// and the moving distances on horizontal and vertical directions by value.
moveCircle function: a void function that passes coordinates of the center by reference, and the moving distances on horizontal and vertical directions by value.
// calculate function: a void function that passes the radius by value, and get back the area
// (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference
// parameters. Assume PI = 3.14 within this function.
calculate function: a void function that passes the radius by value, and get
back the area (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference parameters. Assume PI = 3.14 within this function.
Explanation / Answer
please rate - thanks #include <iostream>using namespace std;
// Function prototypes
//moveCircle function: a void function that passes coordinates of the center by
//reference, and the moving distances on horizontal and vertical directions by value.
void movecircle(int&,int&,int,int);
//calculate function: a void function that passes the radius by value, and get
//back the area (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference parameters. Assume PI = 3.14 within this function.
void calculate(int,double&,double&);
int main( )
{
int x; //x-coordinate of the center
int y; //y-coordinate of the center
int radius; // the radius of the center
int hdist; // moving distance on horizontal direction
int vdist; // moving distance on vertical direction
double area; // area of the circle
double circumference; // circumference of the circle
cin >> x >> y >> radius >> hdist >> vdist; //Read the circle information
// Calculate the new x,y cordinates by calling the moveCircle function
movecircle(x,y,hdist,vdist);
// Calculate the area and the circumference of the circle by calling the calculate function
calculate(radius,area,circumference);
cout << " Center = (" <<x<<","<<y<<")" << " Area = " << area << " Circumference=" << circumference << endl;
system("pause");
return 0;
}
// moveCircle function: a void function that passes coordinates of the center by reference,
// and the moving distances on horizontal and vertical directions by value.
//moveCircle function: a void function that passes coordinates of the center by reference, and the moving distances on horizontal and vertical directions by value.
void movecircle(int& x,int& y,int hdist,int vdist)
{x+=hdist;
y+=vdist;
}
// calculate function: a void function that passes the radius by value, and get back the area
// (PI*radius*radius) and circumference (2*PI*radius) of the circle through reference
// parameters. Assume PI = 3.14 within this function.
void calculate(int r,double& a,double& c)
{double pi=3.14;
a=pi*r*r;
c=2*pi*r;
}
Related 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.