Question: In this lab you will write a java program that creates a class named Circle, this class will be used to create and work with

In this lab you will write a java program that creates a class named Circle, this class will be used to create and work with circles in the plane. Recall that such a circle is determined by its center and radius, where the center is determined by the x-coordinate and the y-coordinate. Your Circle class must contain the following member methods and constructors.

A constructor to create a default circle centered (0,0) with radius 1.

A constructor with one parameter r that allows the user to create a circle of radius r that will by default be centered at (0,0).

A constructor with three parameters, the first two give the x-coordinate and the y-coordinate respectively, and the third is the radius.

A method that returns the area (as double) of the calling object.

A method that returns the circumference (as double) of the calling object.

Your projects should have a class called Test that tests Circle class. This class will include main and should do the following.

1. Write a description informing the user that two circles C1 and C2 will be created based on input

2. Provide a menu selection to see if the user wishes to use a default circle, specify only the radius, or specify x, y, and radius for C1.

1. Default Circle

2. Specify the radius of a circle centered at (0,0)

3. Enter all information about circle

3. Based on the input from the previous step create C1

4. Repeat the previous two steps for C2 instead of C1.

5. Print out on separate lines the information for C1 and C2.

6. Print out the strongest of the following that is true (only one should be printed):

Areas of C1 and C2 are equal.

Area of C1 is greater than C2.

Area of C2 is greater than C1.

7. Ask the user if another pair of circles should be considered. If yes begin again at Step 2. above; otherwise, quit.

TheTestclass must have a static method that asks the user to input the choice of which circle to use; reads the information; and then creates the circle and returns it.

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!