The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Circle:
a) Write a class to represent a Circle called BasicCircle. This should include the following:Â Â
i). A single attribute named radius.Â
ii). A default constructor which will set the value of radius to 1.
iii). A general constructor which should set the radius to a value which is passed to the constructor.
iv). Getter and setter methods for the radius attribute.
v). A method called getCircumference to calculate and return the circumference of the Circle to 2 decimal places (see appendix). You should use Math.PI in this method.Â
vi). A method called getArea to calculate and return the area of the Circle to 3 decimal places (see appendix). You should use Math.PI in this method. Â
Â
b) Write a main method in a new class called TestBasicCircle and in this method:Â
i). Create an array of 3 BasicCircle objects.Â
ii). The radius of each circle should be set by user input.Â
iii). Print the radius of each circle object (see sample output below)
iv). Use the getCircumference()method and print the circumference of each circle.
v). Use the getArea() method and print the area of each circle. (see sample output below)Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly