Skip to main content

Circle divided in 6 equal parts in JAVA Applet.

Circle divided in 6 equal parts=360 degree/6=60 degree of each parts.This code is give a radius of circle and draw a circle and divided each part to 60 degree.Note the r(radius) divided by 45 if the answer is integer from then circle is divided by same degree or else not.

CODING:
 /*<applet code="ca" width=450 height=451>
<param name="radius" value="450">
</applet>*/
import java.applet.*;
import java.awt.*;
public class ca extends Applet
{
  public void paint(Graphics g)
    {
     int R=Integer.parseInt(getParameter("radius"));
     int r=R/2;
     int p=r/45; //if answer is integer from then circle is divided by same degree or else not
      g.drawOval(0,0,R,R);
      g.drawLine(0,r,R,r);
      g.drawLine(p*15,0,p*75,R);
      g.drawLine(p*75,0,p*15,R);
     }
}
OUTPUT

Comments