package com.hcl.
pack;
import java.util.Scanner;
class Rectangle {
private Integer length;
private Integer width;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the length of the rectangle");
length = sc.nextInt();
System.out.println("Enter the width of the rectangle");
width = sc.nextInt();
public Rectangle(Integer length, Integer width){
this.width=width;
this.length=width;
}
public void setLength(Integer length){
this.length=length;
}
public void setWidth(Integer width){
this.width=width;
}
public Integer getLength(){
return length;
}
public Integer getWidth(){
return width;
}
public Integer area() {
Integer area = length*width;
return area;
}
public void display(){
System.out.println("Area of the Rectangle:"+area);
Rectangle dimensionChange(Integer newDimension){
Rectangle rectangleObject = new
Rectangle(length*newDimension,width*newDimension);
return rectangleObject;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the length of the rectangle");
Integer length = sc.nextInt();
System.out.println("Enter the width of the rectangle");
Integer width = sc.nextInt();
System.out.println("Rectangle Dimension");
Rectangle rec = new Rectangle(length,width);
System.out.println("Length:"+rec.getLength());
System.out.println("Width:"+rec.getWidth());
rec.display();
System.out.println("Enter the new dimension");
Integer dimension = sc.nextInt();
Rectangle rec1= rec.dimensionChange(dimension);
if(rec1 instanceof Rectangle){
System.out.println("Rectangle Dimension");
System.out.println("Length:"+rec1.getLength());
System.out.println("Width:"+rec1.getWidth());
rec1.display();
}