472,133 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

program to find the dimensions of a circle

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
9 5378
Ganon11
3,652 Expert 2GB
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
Silent1Mezzo
208 100+
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
i dont now any thing
May 18 '07 #4
Silent1Mezzo
208 100+
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
1,251 Expert 1GB
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
3,237 Expert 2GB
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
14,534 Expert Mod 8TB
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
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
1,251 Expert 1GB
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.

Similar topics

4 posts views Thread by saggie | last post: by
26 posts views Thread by Prime Mover | last post: by
1 post views Thread by ofiras | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.