import java.applet.Applet; import java.awt.*; import java.lang.*; import java.awt.event.*; public class Kaks extends Applet implements MouseListener{ int x, y, x1, y1, x2, y2, x3, y3, k1x, k1y, k2x, k2y, k3x, k3y; double k1, k2, k3, n1, n2, n3; public void init(){ addMouseListener(this); } public void paint(Graphics g){ g.setColor(Color.blue); g.fillRect(0, 0, getSize().width, getSize().height); } int i=1; public void mousePressed(MouseEvent e){ if (i==1){ x=e.getX(); y=e.getY(); Graphics g=getGraphics(); g.setColor(Color.red); g.fillOval(x-2, y-2, 4, 4); x1=x; y1=y; } if (i==2){ x=e.getX(); y=e.getY(); Graphics g=getGraphics(); g.setColor(Color.red); g.fillOval(x-2, y-2, 4, 4); x2=x; y2=y; } if (i==3){ x=e.getX(); y=e.getY(); Graphics g=getGraphics(); g.setColor(Color.red); g.fillOval(x-2, y-2, 4, 4); x3=x; y3=y; g.setColor(Color.black); g.drawLine(x1, y1, x2, y2); g.drawLine(x2, y2, x3, y3); g.drawLine(x3, y3, x1, y1); k1=Math.round(Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))); k2=Math.round(Math.sqrt((x3-x2)*(x3-x2)+(y3-x2)*(y3-x2))); k3=Math.round(Math.sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3))); n1=Math.round( 57.1 *Math.acos( (k3*k3+k1*k1-k2*k2)/(2*k1*k3) ) ); n2=Math.round( 57.1 *Math.acos( (k1*k1+k2*k2-k3*k3)/(2*k1*k2) ) ); n3=Math.round( 57.1 *Math.acos( (k2*k2+k3*k3-k1*k1)/(2*k3*k2) ) ); k1x=(x1+x2)/2; k1y=(y1+y2)/2; k2x=(x2+x3)/2; k2y=(y2+y3)/2; k3x=(x3+x1)/2; k3y=(y3+y1)/2; g.setColor(Color.white); g.drawString(""+n1, x1, y1); g.drawString(""+n2, x2, y2); g.drawString(""+n3, x3, y3); g.drawString(""+k1, k1x, k1y); g.drawString(""+k2, k2x, k2y); g.drawString(""+k3, k3x, k3y); } i++; } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){ Graphics g=getGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, getSize().width, getSize().height); } public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} }