Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Square{
- public static double height;
- public static double width;
- public double getHeight(){
- return height;
- }
- public void setHeight(double h){
- height = h;
- }
- public double getWidth(){
- return width;
- }
- public void setWidth(double w){
- width = w;
- }
- public double getArea(){
- return height * width;
- }
- }
- class t7tester{
- static double h,w,a;
- public static void main(String[] args){
- Square s1 = new Square();
- s1.setHeight(3.0);
- s1.setWidth(4.0);
- h = s1.getHeight();
- w = s1.getWidth();
- a = s1.getArea();
- System.out.println("Height = "+ h);
- System.out.println("Width = "+ w);
- System.out.println("Area = "+ a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement