Create a class called Circle.java with fields named radius, area, and diameter. Include methods named setRadius(), getRadius, and computeDiameter(), which calculates the circle's diameter, and computeArea(), which computes the circle's area. Hint: diameter of a circle is twice its radius. Hint: area of a circle is 3.14 multiplied by the square of the radius. Create a class called TestCircle. java whose main method declares 2 Circle objects. Using setRadius() method, assign one Circle a small radius value and assign another a larger radius value. Call computeDiameter() and computeArea for each circle and display the results
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:
Q2: Create a class called Circle.java with fields named radius, area, and diameter. Include methods named setRadius(), getRadius, and computeDiameter(), which calculates the circle's diameter, and computeArea(), which computes the circle's area.
Hint: diameter of a circle is twice its radius.
Hint: area of a circle is 3.14 multiplied by the square of the radius.
Create a class called TestCircle. java whose main method declares 2 Circle objects. Using setRadius() method, assign one Circle a small radius value and assign another a larger radius value. Call computeDiameter() and computeArea for each circle and display the results
Trending now
This is a popular solution!
Step by step
Solved in 2 steps