Complete the following tasks: a. Design a class named Circle with fields named radius, area, and diameter.

Question:

Complete the following tasks:

a. Design a class named Circle with fields named radius, area, and diameter. Include a constructor that sets the radius to 1. Include get methods for each field, but include a set method only for the radius. When the radius is set, do not allow it to be zero or a negative number. When the radius is set, calculate the diameter (twice the radius) and the area (the radius squared times pi, which is approximately 3.14). Create the class diagram and write the pseudocode that defines the class.

b. Design an application that declares two Circles. Set the radius of one manually, but allow the other to use the default value supplied by the constructor. Then, display each Circle’s values.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: