Question: For java: Create a program that defines a class called circle. Circle should have a member variable called radius that is used to store the

For java:  For java: Create a program that defines a class called circle.

Create a program that defines a class called circle. Circle should have a member variable called radius that is used to store the radius of the circle. Circle should also have a member method called calcArea that calculates the area of the circle using the formula area pi'rM2. Area should NOT be stored in a member variable of circle to avoid stale data Use a global constant for Pl and set it to 3.14159. For now, make radius public and access it directly using the dot operator. Do not worry about input validation for now In main instantiate two objects of class circle and have the user enter a radius for each. Store the radii in the appropriate objects' member variables, then print the radius and area of each circle using the member variable and function Show a test case or cases of your own design proving that this works Lab 16 Modify Lab 15 so that the radius variable in class circle is private. Write a setter and getter method for radius, as well as a default constructor that initializes radius to 0 and a constructor that takes one parameter for radius If radius is given as a negative in a call to the setter or the constructor set it to 0 instead In main, instantiate (declare/create) and use circle objects as needed to prove that all of your functions, including both constructors, work properly (construct a test case for your class in main) Show a test run or runs of your own design proving that everything works

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!