Problem (Circle.java) Implement a class called Circle for representing a circle. The circle has two data members, a Point object representing the center of the circle and a float value representing the radius. Include appropriate constructors for your Circle class. Encapsulate it. Also include methods for finding the area and circumference of the circle. area = pi * radius * radius circumference = 2 * pi * radius. (You may use the static constant pi in the Math class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Problem (Circle.java)

  1. Implement a class called Circle for representing a circle. The circle has two data members, a Point object representing the center of the circle and a float value representing the radius.
  2. Include appropriate constructors for your Circle class.
  3. Encapsulate it.
  4. Also include methods for finding the area and circumference of the circle.

area = pi * radius * radius

circumference = 2 * pi * radius.

(You may use the static constant pi in the Math class)

5. Override the toString() and equals().
Test
Result
Circle c = new Circle();
Radius: 0.00
System.out.printin (c);
Point: (0,0)
c.setRadius (25);
Radius: 25.00
c.setCenter (4,5);
Point: (4,5)
Bystem.out.printin (e);
Circle circle
= new Circle (new MyPoint (1,2), 4.5£) ;
Radius: 4.50
System.out.println(circle);
Point: (1,2)
Circle circle = new Circle (10,20, 11.5£) ;
Radius: 11.50
System.out.println (circle);
Point: (10, 20)
Circle e = new Circle (10,20,5);
Area: 78.54
System.out.printf("Area: 8.2£\n",c.getArea ());
Circumference: 31.42
System.out.-printf ("Circumference: 8.2E",c.getCircumference ());
Transcribed Image Text:Test Result Circle c = new Circle(); Radius: 0.00 System.out.printin (c); Point: (0,0) c.setRadius (25); Radius: 25.00 c.setCenter (4,5); Point: (4,5) Bystem.out.printin (e); Circle circle = new Circle (new MyPoint (1,2), 4.5£) ; Radius: 4.50 System.out.println(circle); Point: (1,2) Circle circle = new Circle (10,20, 11.5£) ; Radius: 11.50 System.out.println (circle); Point: (10, 20) Circle e = new Circle (10,20,5); Area: 78.54 System.out.printf("Area: 8.2£\n",c.getArea ()); Circumference: 31.42 System.out.-printf ("Circumference: 8.2E",c.getCircumference ());
Answer: (penalty regime: 0,0, 0, 0, 5, 10, 15, 20, 30, 50 %)
RESET ANSWER
1 public class MyPoint{
private int x;
private int y;
public MyPoint(){}
5- public MyPoint(int x, int y){
this.x = x;
this.y = y;
2
3
4
6
7
8
9, public String tostring(O{
return "("+x+","+y+")";
10
11
12
13
}
14
CHECK
Transcribed Image Text:Answer: (penalty regime: 0,0, 0, 0, 5, 10, 15, 20, 30, 50 %) RESET ANSWER 1 public class MyPoint{ private int x; private int y; public MyPoint(){} 5- public MyPoint(int x, int y){ this.x = x; this.y = y; 2 3 4 6 7 8 9, public String tostring(O{ return "("+x+","+y+")"; 10 11 12 13 } 14 CHECK
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY