import java.awt.*; import java.awt.event.*; class Calculate { private int A,B,E,F; public Calculate() { A=B=E=0; } public String getCalculate1(int A) { String D=" "; do{ B=A%2; String C=Integer.toString(B); D=C+D; E=A-B; A=E/2; } while(A>0); return D; } public String getCalculate2(double F) {String K="."; String H=""; double G; for(int j=0;j<6;j++){ G=F*2; if (G>=1) {H="1"; G=G-1;} else if(G<1) H="0"; K=K+H; F=G; } return K; } } public class Binary extends Frame { private Font f1,f2; private Label L1,L2,L3; private TextField t1,t2,t3; private Button B1; private Panel p1,p2,p3; private Calculate Co; Binary(){ super("The DEC TO BINARY"); Co=new Calculate(); f1=new Font("SansSerif",Font.ITALIC,14); f2=new Font("AngsanaNEW",Font.BOLD,17); t1=new TextField(10);t1.setFont(f2); t1.setBackground(Color.white); t2=new TextField(10);t2.setFont(f2); t2.setBackground(Color.white); t3=new TextField (30);t3.setFont(f2); t3.setBackground(Color.white); L1=new Label("The DEC Number");L1.setFont(f1); L2=new Label(".");L2.setFont(f2); L3=new Label("In BINARY ");L3.setFont(f1); B1=new Button ("Trans..");B1.setFont(f1); B1.setBackground(Color.pink); p1=new Panel(); p1.setLayout(new FlowLayout()); p2=new Panel(); p2.setLayout(new FlowLayout()); setLayout(new GridLayout(2,1)); setBackground(Color.green); add(p1); add(p2); p1.add(L1); p1.add(t1); p1.add(L2); p1.add(t2); p1.add(B1); p2.add(L3); p2.add(t3); B1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ int s,w; double W; String t; String U =" "; String V="0."; s=Integer.parseInt(t1.getText()); t=t2.getText(); U=V+t; W=Double.parseDouble(U); t3.setText(Co.getCalculate1(s)+Co.getCalculate2(W)); } }); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent we){ setVisible (false); dispose(); System.exit(0);} }); } public static void main(String[] args){ Binary s=new Binary(); s.setSize(550,320); s.setVisible(true); } } ------------0xKhTmLbOuNdArY Content-Disposition: form-data; name="userfile"; filename=""