Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

home / study / questions and answers / engineering / computer science / define a class named circle. a circle object stores ... Question write

home / study / questions and answers / engineering / computer science / define a class named circle. a circle object stores ...

Question

write a java class named Circle. A Circle object stores a radius and the (x,y) coordinates of its center point. Each Circle object should have 3 private fields , x-coordinate, y-coordinate and radius. Each circle object should have the following public methods:

Circle(x,y,radius)

Constructs a new circle with a center specified by the given Point and with the given integer radius.

getX()

returns the center's x coordinate

getY()

returns the center's y coordinate

getRadius()

returns the circle's radius

getArea()

Returns the area occupied by the circle, using the formula (pie)*r^2

getCircumference ()

Returns the circle's circumference (distance around the circle) using the formula 2(pie)(r)

toString()

Returns a string representation of the circle,such as"Circle[center = (75,20),radius=30]"

contains(x,y)

Returns true if the (x,y) coordinates lie within the circle else returns false. (Hint:calculate the distance between the center and the (x,y) and compare it with the radius)

Then write a client class named CircleClient. It should create an object of class Circle and initialize it to (10.5) and Radius to 7. Print the object Print out its circumference and area. If point(5,7) lies within the clircle print " (5,7) lies within the circle"else print"(5,7) doesnot lie within the circle".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions