By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,537 Members | 873 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,537 IT Pros & Developers. It's quick & easy.

program to find the dimensions of a circle

P: 2
Given the center and a point on the circle, you can use this formula to find the radius of the circle. 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: a. distance: This function takes as its parameters four numbers that represent two points in the plane and returns the distance between them. b. Radius : This function takes as its parameters four number 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. c. 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) d. 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 π r2 ) Assume that π = 3.1416
May 18 '07 #1
Share this Question
Share on Google+
9 Replies


Ganon11
Expert 2.5K+
P: 3,652
Interesting problem. Were you having trouble with this? Did you have a program that you were getting errors on? Trouble understanding the problem? We can't help you if you won't help yourself.
May 18 '07 #2

100+
P: 208
Sounds like a program I did in my first programmer coures :P It's really not hard. There's algorithms on the net
May 18 '07 #3

P: 2
i dont now any thing
May 18 '07 #4

100+
P: 208
WEll think about this for a moment..Now...I'm assuming when you say the user enters the center and another point that this second point is on the edge of the circle (It has to be unless you're given a ratio of where it's located (e.g. the point is 2/3 away from the center)).

Anyways...Given the center and a point on the edge it's really easy to calculate the radius and diameter....Just calculate the length of the line...
May 18 '07 #5

AdrianH
Expert 100+
P: 1,251
i dont now any thing
I'm sorry? I think you know a lot more than you realise. You've got your problem, now tell me what steps you need to do to solve it.

Don't post code at this point. Assume that the computer is a person that will follow instructions. You talk to the person as input, the person does something and then talks back for output.

Now, what you need to think about is:
  • what are you going to say to the person?
  • what is the person going to have to do (i.e. what calculations will it need to do)?
  • what is the person going to say to you?

Frame your solution like:

person says, "What is the mass in grams?"
you say, "<some number>"
person stores m=<some number>
person calculates E=m*(c^2) where ^ means to the power of
person says "The energy in " m " grams is " E " Joules"


Adrian
May 18 '07 #6

Motoma
Expert 2.5K+
P: 3,235
i dont now any thing
LOL. In that case, you need more help than this forum will be able to provide.
May 18 '07 #7

MMcCarthy
Expert Mod 10K+
P: 14,534
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you.


Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

ADMIN
May 19 '07 #8

JalapenoBob
P: 1
Given the center and a point on the circle, you can use this formula to find the radius of the circle. 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: a. distance: This function takes as its parameters four numbers that represent two points in the plane and returns the distance between them. b. Radius : This function takes as its parameters four number 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. c. 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) d. 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 π r2 ) Assume that π = 3.1416

OK, Let's get serious here....

Let us call your two points A and B. Your four numbers are then Ax, Ay, Bx, By. The length, L, of the line between these points is:
' Visual Basic
L = sqr( (Ax - Bx) ^ 2 + (Ay - By) ^ 2 )
/* C and C++ */
L = sqrt( pow( Ax - Bx, 2 ) + pow( Ay - By, 2 ) )
Since one of these points is the center of the circle and the other is on the circumference, this line is a radius of the circle. Therefore:
radius = L
diameter = 2 * L
circumference = 2 * pi * L
area = pi * ( L ^ 2 )
See how easy this is?? Have fun with it.....
May 19 '07 #9

AdrianH
Expert 100+
P: 1,251
OK, Let's get serious here....

Let us call your two points A and B. Your four numbers are then Ax, Ay, Bx, By. The length, L, of the line between these points is:
' Visual Basic
L = sqr( (Ax - Bx) ^ 2 + (Ay - By) ^ 2 )
/* C and C++ */
L = sqrt( pow( Ax - Bx, 2 ) + pow( Ay - By, 2 ) )
Since one of these points is the center of the circle and the other is on the circumference, this line is a radius of the circle. Therefore:
radius = L
diameter = 2 * L
circumference = 2 * pi * L
area = pi * ( L ^ 2 )
See how easy this is?? Have fun with it.....
Well saraaana, looks like JalapenoBob has given you part of the solution. Can you supply the rest?


Adrian
May 19 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.