
Annulus Problem
While I am learning Java, I am having a small problem trying to solve a problem. I hope someone can help me:
I am required to develop a small program to calculate the Area of an Annulus :mad:
======
I have written down my thoughts about this problem.
An annulus can be thought of as two concentric circles (They are drawn with a common centre point). To determine the area of the annulus all I need to do is subtract the area of the smaller circle from the larger circle.
To determine the area of a circle, I will need the radius (or divide the diameter by 2). Then it's simply a matter of good old TTr2 (pi * (radius * radius)) to determine the area.
Eg. Lets say we are told that the diameter of the inner edge of the annulus is 10, and the diameter of the outer edge of the annulus is 15 :
For the sake of argument I will round TT to 3.14159
Area of first circle:
Radius = diameter/2 = 5
Area = TTr2 = 3.14159 * ( 5 * 5 ) = 78.53975
Area of second circle:
Radius = diameter/2 = 7.5
Area = TTr2 = 3.14159 * ( 7.5 * 7.5 ) = 176.7144375
Annulus
Area = Area of large circle – Area of small circle
Area = 176.7144375 – 78.53975 = 98.1746875
=======
At this stage, I am still unsure how to write a Java program :confused: but I must say that it's my first time learning this! Can anyone help me please?
Thanks!

1 Attachment(s)
Hi, btaylor
I have to admit I've never even heard of the concept of the annulus. However, your definition and descriptions were so concise that I now know what it is all about.:)
You appear to be mere inches away from completing your task. All you have to do is convert the mathematics into Java code, and allow a user to enter the necessary data and display the results.
subTotal1=3.14159*(bigRadius*bigRadius);// larger radius is squared and multiplied by 3.14159
subTotal2=3.14159*(littleRadius*littleRadius);
annResult=subTotal1subTotal2;
resultText.setText(Double.toString(annResult));// convert result to double and display it in the GUI
The above snippet is from a very rough application I've written as per your instructions. The variables subTotal1 and subTotal2 contain the values entered by a user. Each is squared and then multiplied by PI. The final result is obtained by subtracting the smaller from the larger.
If you want to have a look at the full program, I've included it as an attachment. I should stress that it is ROUGH and I haven't catered for users being naughty and entering rogue data. I should also stress that I've asked for the RADIUS to be entered. If you want the Diameter entered, change the code accordingly and divide by 2 to get the radius for the arithmatic as usual.
Once downloaded, save it as Annulus.java (not as a .txt) and compile as normal (javac Annulus.java) and then run it from the command prompt (java Annulus).
Hope it helps.
JoyousMonkey
P.S.
If this is too technical or not technical enough please let me know.