Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter, and pi is declared as double. Create the following for the Circle object: ● Implicit constructor (default constructor) ● Void method Calculate (double pi, int radius) to calculate the area of the Circle object. The method must include a system.out statement that displays the area value. Use the following formula to calculate area of the circle: Area = pi * (r * r) Your program includes a main class called Shape with a reference c1 to the Circle object. Pass the following values to the object Circle: radius = 4 diameter = 8 pi = 3.14 Include output statements to view the values passed to the object Circle.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter, and pi is declared as double. Create the following for the Circle object:
● Implicit constructor (default constructor)
● Void method Calculate (double pi, int radius) to calculate the area of the Circle object. The method must include a system.out statement that displays the area value. Use the following formula to calculate area of the circle:
Area = pi * (r * r)
Your program includes a main class called Shape with a reference c1 to the Circle object. Pass the following values to the object Circle:
radius = 4
diameter = 8
pi = 3.14
Include output statements to view the values passed to the object Circle.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images