Question: You will type the class Circle and the class TestProgCircle in two separate files). Run and test the program with the data given: In this
You will type the class Circle and the class TestProgCircle in two separate files). Run and test the program with the data given:
In this example, we give the complete definition of the class Circle, which was briefly discussed in the beginning of this chapter. public class Circle { private double radius; //Default constructor //Sets the radius to 0 Circle () radius 0; //Constructor with a parameter //Sets the radius to the value specified by the parameter r. Circle (double r) radius r; //Method to set the radius of the circle. //Sets the radius to the value specified by the parameter r. public void setRadius (double r) radius r ). //Method to return the radius of the circle. //Returns the radius of the circle, public double getRadius () { ) //Method to compute and return the area of the circle. //Computes and returns the area of the circle. public double area () ( return Math.PI Math.PI radius; () return radius; //Method to compute and return the perimeter of the circle. //Computes and returns the area of the circle. public double perimeter () ) return 2 Math.PI radius: //Method to return the radius, area, parimeter of the circle //as a string.
Step by Step Solution
3.39 Rating (161 Votes )
There are 3 Steps involved in it
Circlejava Java file to create the Circle class public class Circle private double radius attribute ... View full answer
Get step-by-step solutions from verified subject matter experts
