Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: image text in transcribed
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

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

More Books

Students also viewed these Databases questions

Question

2. What are the possible cause(s) for the problem? (See Tool #9.)

Answered: 1 week ago