Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class Square{
  2. public static double height;
  3. public static double width;
  4. public double getHeight(){
  5. return height;
  6. }
  7. public void setHeight(double h){
  8. height = h;
  9. }
  10. public double getWidth(){
  11. return width;
  12. }
  13. public void setWidth(double w){
  14. width = w;
  15. }
  16. public double getArea(){
  17. return height * width;
  18. }
  19. }
  20.  
  21.  
  22. class t7tester{
  23.  
  24. static double h,w,a;
  25. public static void main(String[] args){
  26.  
  27. Square s1 = new Square();
  28. s1.setHeight(3.0);
  29. s1.setWidth(4.0);
  30. h = s1.getHeight();
  31. w = s1.getWidth();
  32. a = s1.getArea();
  33. System.out.println("Height = "+ h);
  34. System.out.println("Width = "+ w);
  35. System.out.println("Area = "+ a);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement