Rectangle Dimension Change(Main.java)

 import java.io.*;

import java.util.Scanner;


public class Main {
    public static void main(String[] args) throws Exception, IOException {
        Scanner sc = new Scanner(System.in);
          System.out.println("Enter the length of the rectangle");
          int a;
          a = sc.nextInt();
          System.out.println("Enter the width of the rectangle");
          int b;
          b = sc.nextInt();
         Rectangle r1 = new Rectangle(a,b);
         r1.display();
         System.out.println("Area of the Rectangle:"+r1.area());
         System.out.println("Enter the new dimension");
         int re = sc.nextInt();
        Rectangle r2 = r1.dimensionChange(re);
         if(r2 instanceof Rectangle) {
            
           
            
             r2.display();
             System.out.println("Area of the Rectangle:"+r2.area());
         }
    }}



                   
                        

        



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.