Create a class named circle with fields named radius area


#1

Create a class named Pizza. Data fields include a string for toppings (such as pepperoni), an integer for diameter in inches (such as 12), and a double for price (such as 13.99). Include properties to get and set values for each of these fields. Create a class named TestPizza that instantiates one Pizza object and demonstrates the use of the Pizza set and get accessors. Save this class as TestPizza.cs.

#2

Create a class named Circle with fields named radius, area, and diameter. Include a constructor that sets the radius to 1. Also include public properties for each field. The Radius property should have get and set accessors, but Area and Diameter should be read-only. The set accessor for the radius should also provide values for the diameter and area. (The diameter of a circle is twice its radius; the area is pi multiplied by the square of the radius. You can use the public Math class property Math. PI for the value of pi.) Create a class named TestCircles whose Main( ) method declares three Circle objects. Assign a small radius value to one Circle and assign a larger radius value to another Circle. Do not assign a value to the radius of the third circle; instead, retain the value assigned at construction. Display the radius, diameter, and area for each Circle. (Display the area to two decimal places.) Save the program as TestCircles.cs.

#3

Create a class named Square that contains fields for area and the length of a side and whose constructor requires a parameter for the length of one side of a Square. The constructor assigns its parameter to the length of the Square's side field and calls a private method that computes the area field. Also include read-only properties to get a Square's side and area. Create a class named DemoSquares that instantiates an array of 10 Square objects with sides that have values of 1 through 10. Display the values for each Square. Save the class as DemoSquares.cs.

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Create a class named circle with fields named radius area
Reference No:- TGS01674779

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)