Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods: A private variable of type

JAVA

Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods:

A private variable of type double named radius to represent the radius. Set to 1.

Constructor Methods:

Python : An overloaded constructor method to create a default circle.

C# & Java: Default Constructor with no arguments.

C# & Java: Constructor method that creates a circle with user-specified radius.

Method getRadius() that returns the radius.

Method setRadius() that sets the radius.

Method getArea() that returns the area.

Method getCircumference() that returns the circumference.

Method To String,

Java: toString()

C#: ToString()

Python: __str__(self)

that prints out a meaningful description of the circle as follows:

The circle has radius X. Where X is the value of variable radius.

Now design and implement a test program to create a default circle object and test all class methods on the object. Print the object after each method call and use meaningful label for each method call as shown in the following sample run.

Sample run:

Print radius:

The radius is 1.

Print area:

The area is 3.14

Print circumference:

The perimeter is 6.28

Set radius to 10 and print the object: The circle has radius 10.

Print area:

The area is 314.23

Print circumference:

The perimeter is 62.81

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

OUTLINE the five steps in the labour relations process.

Answered: 1 week ago

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago