Question 1 Draw a Circle 50 points Before starting this ques
Solution
package circleSquarePackage;
import javax.swing.JComponent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Ellipse2D.Double;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.color;
import java.awt.Dimension;
public class drawingcircle extends JComponent{
private Ellipse2D.Double sphere;
private int radii;
double circum,area;
public circle(){
sphere=new Ellipse2D.Double();
}
public void setSphere(Ellipse2D.Double sphere){
this.sphere=sphere;
}
public circle(int xAxis,int yAxis,int rad)
{
sphere=new Ellipse2D.Double(xax,yax,ra,ra);
}
public double calcarea()
{
return area=math.pi*ra*a;
}
public void inpx(){
int x=Integer.parseInt(JOptionPane.showInputDialog(null,Enter x-coordiante\");
double y=sphere.y;
Ellipse2D.Double newSphere= new Ellipse2D.Double(x,y,size,size);
setSphere(newSphere);
}
public void inpy(){
int y=Integer.parseInt(JOptionPane.showInputDialog(null,Enter x-coordiante\");
double x=sphere.x;
Ellipse2D.Double newSphere= new Ellipse2D.Double(x,y,size,size);
setSphere(newSphere);
}
public void inpRadi(){
int r=Integer.parseInt(JOptionPane.showInputDialog(null,\'enter radius\");
int size=r*2;
Ellise2D.Double newSphere = new Ellise2D.Double(x,y,size,size)
setSphere(newSphere); }
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g22 = (Graphics2D) g;
g22.draw(sphere);
}
}
write all import statements:-
public class CircleTester{
int x=Integer.parseInt(JOptionPane.showInputDialog(null,Enter x-coordiante\");
int y=Integer.parseInt(JOptionPane.showInputDialog(null,Enter y-coordiante\");
int rad=Integer.parseInt(JOptionPane.showInputDialog(null,Enter rad-coordiante\");
int si=rad*2;
return new Ellipse2D.Double(x,y,si,si);}
public static void main(string[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
Jframe fr= new JFrame();
fr.setVisible(true);
}
});
}}


