Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /*Name:Chris McGlynn
  2. Date: 27/09
  3. Program to find measurements of a circle
  4. */
  5.  
  6. import java.text.DecimalFormat;
  7.  
  8. public class Circle1 {
  9.  
  10. public static void main (String [] args) {
  11.  
  12.  
  13. DecimalFormat df = new DecimalFormat("00.00");
  14.  
  15.  
  16. Double radius=8.25;
  17. Double diameter=2*radius; //theory for diameter
  18. Double circumference=2*Math.PI*radius; //theory for circumference
  19.  
  20.  
  21. Double areaOfCircle;
  22.  
  23. areaOfCircle = Math.PI * Math.pow(radius,2); //theory for area
  24.  
  25. System.out.println ("The area is "+df.format(areaOfCircle)+" units squared");
  26. System.out.println ("The diameter of the circle is " +df.format(diameter) + (" units"));
  27. System.out.println ("The circumference of the circle is " +df.format (circumference) + (" units"));
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. }
  46.  
  47. }
  48.  
  49.  
  50. /*The radius is 4.50 units
  51. The diameter is 9.00 units
  52. The circumference is 28.27 units
  53. The area is 63.62 units squared
  54. Diameter = 2 * radius
  55. Circumference = 2 * π * radius
  56. Area = π * (radius) 2
  57. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement