Write the Class for Circle. Read the following code and create the attributes, method, constructors of class according so that it produces the output as given below.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 Write the Class for Circle. Read the following code and create the attributes, method, constructors of class according so that it produces the output as given below.

Code:

publicclass Main {

 

      publicstaticvoidmain(String[] args) {

            System.out.println("Value of PI: "+ Circle.PI);

            System.out.println("Square of 2.0 is: " + Circle.square(2.0));

            Circle c1 = newCircle(3.4);

            Circle c2 = newCircle(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
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education