Write the Class for Circle. Read the following code and create the attributes, method, constructors of class according so that it produces the result as given below. Code: public class Main { public static void main(String[] args) { System.out.println("Value of PI: "+ Circle.PI); System.out.println("Square of 2.0 is: " + Circle.square(2.0)); Circle c1 = new Circle(3.4); Circle c2 = new Circle(2.9); c1.display(); c2.display(); System.out.println(c1.compare(c2)); System.out.println(c2.compare(c1)); c1 = c2.getCopy(); System.out.println(c1.compare(c2)); System.out.println(c2.compare(c1)); c1.set(5.0); System.out.println(c1.getRadius()); System.out.println(c1.getDiameter()); System.out.println(c1.getCircumference()); System.out.println(c1.getArea()); Circle c3 = c2.getClone(); c3.set(c1.getDiameter()); c2.display(); c3.set(c1); c1.display(); c2.display(); c3.display(); } } Output: Value of PI: 3.14 Square of 2.0 is: 4.0 Radius: 3.4, Diameter: 6.8, Circumference: 21.352, Area: 36.2984 Radius: 2.9, Diameter: 5.8, Circumference: 18.212, Area: 26.407400000000003 1 -1 0 0 5.0 10.0 31.400000000000002 78.5 Radius: 10.0, Diameter: 20.0, Circumference: 62.800000000000004, Area: 314.0 Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5 Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5 Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5

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
100%

: Write the Class for Circle. Read the following code and create the attributes, method, constructors of class according so that it produces the result as given below.
Code:
public class Main {

public static void main(String[] args) {
System.out.println("Value of PI: "+ Circle.PI);
System.out.println("Square of 2.0 is: " + Circle.square(2.0));
Circle c1 = new Circle(3.4);
Circle c2 = new Circle(2.9);
c1.display();
c2.display();
System.out.println(c1.compare(c2));
System.out.println(c2.compare(c1));
c1 = c2.getCopy();
System.out.println(c1.compare(c2));
System.out.println(c2.compare(c1));
c1.set(5.0);
System.out.println(c1.getRadius());
System.out.println(c1.getDiameter());
System.out.println(c1.getCircumference());
System.out.println(c1.getArea());
Circle c3 = c2.getClone();
c3.set(c1.getDiameter());
c2.display();
c3.set(c1);
c1.display();
c2.display();
c3.display();
}
}
Output:
Value of PI: 3.14
Square of 2.0 is: 4.0
Radius: 3.4, Diameter: 6.8, Circumference: 21.352, Area: 36.2984
Radius: 2.9, Diameter: 5.8, Circumference: 18.212, Area: 26.407400000000003
1
-1
0
0
5.0
10.0
31.400000000000002
78.5
Radius: 10.0, Diameter: 20.0, Circumference: 62.800000000000004, Area: 314.0
Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5
Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5
Radius: 5.0, Diameter: 10.0, Circumference: 31.400000000000002, Area: 78.5

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 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