1 way Easy without loop
CODING:
/*<applet code="cor" width=455 height=455>
<param name="radius" value="180">
</applet>*/
import java.applet.*;
import java.awt.*;
public class cor extends Applet {
public void paint(Graphics g){
int R=Integer.parseInt(getParameter("radius"));
int d=R*2;
g.drawOval(0,0,d,d);
g.drawLine(R,0,R,d);
g.drawLine(0,R,d,R);
}
}
<param name="radius" value="180">
</applet>*/
import java.applet.*;
import java.awt.*;
public class cor extends Applet {
public void paint(Graphics g){
int R=Integer.parseInt(getParameter("radius"));
int d=R*2;
g.drawOval(0,0,d,d);
g.drawLine(R,0,R,d);
g.drawLine(0,R,d,R);
}
}
OUTPUT
2 way Easy with loop
CODING:
/*<applet code="cor" width=455 height=455>
<param name="radius" value="180">
</applet>*/
import java.applet.*;
import java.awt.*;
public class cor extends Applet{
public void paint(Graphics g){
int R=Integer.parseInt(getParameter("radius"));
int x,d=R*2;
double i=R+1;
g.drawOval(0,0,d,d);
for(x=R;i>=R;x--)
{ i=Math.sqrt(x*x*2); }
g.drawLine(R-x,R-x,d-(R-x),d-(R-x));
g.drawLine(d-(R-x),R-x,R-x,d-(R-x));
}
}
<param name="radius" value="180">
</applet>*/
import java.applet.*;
import java.awt.*;
public class cor extends Applet{
public void paint(Graphics g){
int R=Integer.parseInt(getParameter("radius"));
int x,d=R*2;
double i=R+1;
g.drawOval(0,0,d,d);
for(x=R;i>=R;x--)
{ i=Math.sqrt(x*x*2); }
g.drawLine(R-x,R-x,d-(R-x),d-(R-x));
g.drawLine(d-(R-x),R-x,R-x,d-(R-x));
}
}
OUTPUT
Comments
Post a Comment