Guest User

Untitled

a guest
Apr 27th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Ring {
  2. double radius1;
  3. double radius2;
  4. double pi = 3.14;
  5.  
  6. Ring(double r1, double r2) {
  7. radius1 = r1;
  8. radius2 = r2;
  9. }
  10.  
  11. double ring1() {
  12. return pi * Math.pow(radius1, 2);
  13. }
  14.  
  15. double ring2() {
  16. return pi * Math.pow(radius2, 2);
  17. }
  18.  
  19. }
  20.  
  21. class Circle {
  22. public static void main(String[] args) {
  23.  
  24. Ring testRing = new Ring(7, 5);
  25.  
  26. double a = testRing.ring1();
  27. double b = testRing.ring2();
  28. double c = a - b;
  29.  
  30. System.out.println(a);
  31. System.out.println(b);
  32. System.out.println(c);
  33. }
  34. }
Add Comment
Please, Sign In to add comment