The Ellipse2DDemo class This class will consists oftwo metho
Solution
Ellipse2D.java
import java.lang.Math;
 public class Ellipse2D{
     double x, y, w, h;
    public Ellipse2D(double x, double y, double w, double h){
         this.x = x;
         this.y = y;
         this.w = w;
         this.h = h;
     }
    public double getArea(){
         return Math.PI*w*h;
     }
    public void setWidth(double width){
         this.w = width;
     }
    public void setHeight(double height){
         this.h = height;
     }
    public double getPerimeter(){
         return 2*Math.PI*Math.sqrt((w*w + h*h)/2.0);
     }
 }
Ellipse2DDemo.java
//import java.awt.geom.Ellipse2D.Double;
 import java.util.Scanner;
 public class Ellipse2DDemo{
    public static void printEllipseDetails(double x, double y, double w, double h, double area, double perimeter){
         System.out.printf(\"Ellipse2D[x=%.5f, y=%.5f, w=%.5f, h=%.5f]\", x, y, w, h);
         System.out.printf(\"\ location: (%.5f, %.5f)\", x, y);
         System.out.printf(\"\ width:   %.5f   height:   %.5f\", w, h);
         System.out.printf(\"\ area:    %.5f   perimeter:   %.5f\", area, perimeter);
     }
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         double x, y, w, h;
         double area1, perimeter1, area2, perimeter2;
         System.out.print(\"Enter the value of x: \");
         x = sc.nextDouble();
         System.out.print(\"Enter the value of y: \");
         y = sc.nextDouble();
         System.out.print(\"Enter the value of width: \");
         w = sc.nextDouble();
         System.out.print(\"Enter the value of height: \");
         h = sc.nextDouble();
        while(w<h){
             System.out.println(\"Please enter the value of width greater than height\");
             System.out.print(\"Enter the value of width: \");
             w = sc.nextDouble();
             System.out.print(\"Enter the value of height: \");
             h = sc.nextDouble();
         }
        Ellipse2D ellipse1 = new Ellipse2D(x, y, w, h);
         area1 = ellipse1.getArea();
         perimeter1 = ellipse1.getPerimeter();
         System.out.println(\"Description of the first ellipse:\");
         System.out.println(\"--------------------------------------------------------------------------------\");
          printEllipseDetails(x, y, w, h, area1, perimeter1);
        Ellipse2D ellipse2 = new Ellipse2D(x, y, w, h);
         System.out.println(\"Description of the second ellipse:\");
         System.out.println(\"--------------------------------------------------------------------------------\");
          printEllipseDetails(x, y, w, h, area1, perimeter1);
        Ellipse2D ellipse2modified = new Ellipse2D(x, y, w, h);
         ellipse2modified.setWidth(h);
         area2 = ellipse2modified.getArea();
         perimeter2 = ellipse2modified.getPerimeter();
         System.out.println(\"Description of the second ellipse after it is modified:\");
         System.out.println(\"--------------------------------------------------------------------------------\");
          printEllipseDetails(x, y, w, h, area2, perimeter2);
        double areaDifference = area1-area2;
         System.out.printf(\"\ The area between the first and second ellipses is %.5f\ \", areaDifference);
     }
 }


