Question: Change the below code in Java using JOptionPane import java.util.ArrayList; import java.util.Scanner; public class Application { public static void main(String[] args) { //Declaring variables int
Change the below code in Java using JOptionPane
import java.util.ArrayList; import java.util.Scanner;
public class Application {
public static void main(String[] args) { //Declaring variables int x,y; double radius,height; //Creating an ArrayList Object ArrayList arl=new ArrayList(); /* Scanner class object is used to * read the inputs entered by the user */ Scanner sc=new Scanner(System.in); //Getting the point coordinates entered by the user System.out.print("Enter the X coordinate of Point :"); x=sc.nextInt(); System.out.print("Enter the Y coordinate of Point :"); y=sc.nextInt(); //Getting the radius of the circle enterd by the user System.out.print("Enter radius of the Circle :"); radius=sc.nextDouble(); //Getting the height of the circle entered by the user System.out.print("Enter Height of the Cylinder :"); height=sc.nextDouble(); /* Creating a Point class object by passing * the x,y coodinates as arguments */ Point p=new Point(x, y); //Adding the Point class object to the ArrayList arl.add(p); /* Creating a Circle class object by passing * the x,y coodinates and radius as arguments */ Circle c=new Circle(x, y, radius); //Adding the Circle class object to the ArrayList arl.add(c); /* Creating a Cylinder class object by passing * the x,y coodinates, radius,height as arguments */ Cylinder cyl=new Cylinder(x, y, radius, height); //Adding the Cylinder class object to the ArrayList arl.add(cyl); //Displaying Each object Information System.out.println("_____Displaying each Object Information_____"); for(Object o:arl) { System.out.println(o.toString()); System.out.println("_________________"); }
}
}