您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 其它相关文档 > 计算机组成原理算法视线—定点整数的操作
packagesrc;importjava.awt.*;importjava.awt.event.*;importjavax.swing.JOptionPane;publicclassZuChengextendsFrameimplementsActionListener{staticinti=0;staticintm=1;Labela1,a2;TextFieldtext1;Buttonbutton1,m1,m2,m3,m4,m5;Fontf;ZuCheng(Strings){super(s);setLayout(null);f=newFont(黑体,Font.BOLD,20);m1=newButton(定点整数机器表示);m2=newButton(定点整数变形补码加减法);m3=newButton(定点整数原码乘法);m4=newButton(浮点加减法);m5=newButton(帮助);m1.addActionListener(this);m2.addActionListener(this);m3.addActionListener(this);m4.addActionListener(this);m5.addActionListener(this);m1.setBounds(10,30,120,25);m2.setBounds(140,30,140,25);m3.setBounds(290,30,120,25);m4.setBounds(420,30,80,25);m5.setBounds(510,30,80,25);add(m1);add(m2);add(m3);add(m4);add(m5);a1=newLabel(计算机组成原理算法实现(一),Label.CENTER);a2=newLabel(输入口令(123):);a1.setBounds(180,100,300,40);a1.setBackground(Color.pink);a1.setFont(f);a2.setBounds(180,200,90,25);a2.setBackground(Color.gray);text1=newTextField(18);text1.setBounds(280,200,200,25);button1=newButton(确认);button1.setBounds(300,250,70,30);button1.addActionListener(this);add(a1);add(a2);add(text1);add(button1);setBackground(Color.lightGray);setBounds(100,100,600,400);setVisible(true);validate();addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});}publicstaticvoidmain(Stringargs[]){ZuChengz1=newZuCheng(计算机组成原理);}publicvoidactionPerformed(ActionEvente){Strings=newString(123);if(e.getSource()==button1){while(i==0&&m=3&&(!(text1.getText().equals()))){if(text1.getText().equals(s)){i=1;JOptionPane.showMessageDialog(this,口令正确,请选择菜单栏的操作,正确,JOptionPane.INFORMATION_MESSAGE);}else{m++;JOptionPane.showMessageDialog(this,您输入的密码不正确,警告对话框,JOptionPane.WARNING_MESSAGE);text1.setText(null);}}if(m3){JOptionPane.showMessageDialog(this,您已被禁用,错误对话框,JOptionPane.ERROR_MESSAGE);}}if(i==1){if(e.getSource()==m1){Shows1=newShow(机器数表示);s1.setVisible(true);}elseif(e.getSource()==m2){Form3f1=newForm3();f1.setTitle(定点变形补码加减);f1.setVisible(true);}elseif(e.getSource()==m3){Form4f2=newForm4();f2.setTitle(定点原码乘法);f2.setVisible(true);}elseif(e.getSource()==m4){Form5f5=newForm5(浮点加减);f5.setVisible(true);}elseif(e.getSource()==m5){Helph1=newHelp(帮助信息);h1.setVisible(true);h1.work();}}}}packagesrc;importjava.awt.*;importjava.awt.event.*;publicclassShowextendsFrameimplementsActionListener{intme=0;Labelb1,b2,b3;Fontf;TextFieldt1,t2;Buttonbutton1,button2,button3,button4,button5,button6;Show(Strings){super(s);setLayout(null);f=newFont(黑体,Font.BOLD,20);b1=newLabel(定点整数的机器表示);b2=newLabel(请输入一个二进制数:);b3=newLabel(该数对应的原码为:);b1.setBounds(180,100,250,40);b1.setFont(f);b1.setBackground(Color.pink);b2.setBounds(100,200,120,25);b3.setBounds(100,250,120,25);b2.setBackground(Color.gray);b3.setBackground(Color.gray);t1=newTextField(15);t2=newTextField(15);t1.setBounds(250,200,200,25);t2.setBounds(250,250,200,25);button1=newButton(输入);button2=newButton(原码);button3=newButton(反码);button4=newButton(补码);button5=newButton(移码);button6=newButton(返回);button1.setBounds(80,350,70,25);button2.setBounds(160,350,70,25);button3.setBounds(240,350,70,25);button4.setBounds(320,350,70,25);button5.setBounds(400,350,70,25);button6.setBounds(480,350,70,25);setBounds(100,100,600,400);setBackground(Color.lightGray);add(b1);add(b2);add(b3);add(t1);add(t2);add(button1);add(button2);add(button3);add(button4);add(button5);add(button6);button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);button4.addActionListener(this);button5.addActionListener(this);button6.addActionListener(this);validate();addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){setVisible(false);}});}publicvoidactionPerformed(ActionEvente){if(e.getSource()==button1){me=1;t1.requestFocusInWindow();}elseif(me==1){if(e.getSource()==button2){Strings1=t1.getText().trim();intx=Integer.valueOf(s1,2);if(x0){StringBuffers11=newStringBuffer(s1);s11.setCharAt(0,'1');t2.setText(s11.toString());}elseif(x0){StringBuffers22=newStringBuffer(s1);s22.setCharAt(0,'0');t2.setText(s22.toString());}}elseif(e.getSource()==button3){Strings=t1.getText().trim();intx=Integer.valueOf(s,2);intt=s.length()-1;if(x0){StringBuffers1=newStringBuffer(s);s1.deleteCharAt(0);StringBuffers2=newStringBuffer(t1.getText().trim());s2.deleteCharAt(0);for(inti=0;is1.length();i++){s2.setCharAt(i,'1');}Strings21=s2.toString();Strings11=s1.toString();inti1=Integer.valueOf(s11,2);inti2=Integer.valueOf(s21,2);Strings3=Integer.toBinaryString(i2^i1);if(t!=s3.length()){StringBuffers4=newStringBuffer(s3);s4.insert(0,'0');s3=s4.toString();}t2.setText(1+s3);}elseif(x0){StringBuffers1=newStringBuffer(s);s1.deleteCharAt(0);Strings11=s1.toString();t2.setText(0+s11);}}elseif(e.getSource()==button4){Strings=t1.getText().trim();intx=Integer.valueOf(s,2);intt=s.length()-1;Stringsub=1;intsub1=Integer.valueOf(sub,2);if(x0){StringBuffers1=newStringBuffer(s);s1.deleteCharAt(0);StringBuffers2=newStringBuffer(t1.getText().trim());s2.deleteCharAt(0);for(inti=0;is1.length();i++){s2.setCharAt(i,'1');}Strings21=s2.toStri
本文标题:计算机组成原理算法视线—定点整数的操作
链接地址:https://www.777doc.com/doc-7335449 .html