




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、 田 arc:f. Form?java J Fom4,java;J_i Form5.javal 也 Helpjava ,f| Showjavai ZuChengJavapackage src;import java.awt.*;import java.awt.event.*;import javax.swing.JOptionPane;public class ZuCheng extends Frame implements ActionListener ( static int i=0;static int m=1;Label a1,a2;TextField text1;Button but
2、ton1,m1,m2,m3,m4,m5;Font f;ZuCheng(String s) ( super(s);setLayout(null);f=new Font(黑體,Font.BOLD,20);m1=new Button(定點(diǎn)整數(shù)機(jī)器表示);m2=new Button(定點(diǎn)整數(shù)變形補(bǔ)碼加減法);m3=new Button(定點(diǎn)整數(shù)原碼乘法);m4=new Button(浮點(diǎn)加減法);m5=new Button(幫助); m1.addActionListener(this);m2.addActionListener(this);m3.addActionListener(this);m4.a
3、ddActionListener(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=new Label(計(jì)算機(jī)組成原理算法實(shí)現(xiàn)(一) ,Label.CENTER);a2=new Label(輸入口令(123):);a1.se
4、tBounds(180,100,300,40);a1.setBackground(Color.pink);a1.setFont(f);a2.setBounds(180,200,90,25);a2.setBackground(Color.gray);text1=new TextField(18);text1.setBounds(280,200,200,25);button1=new Button(確認(rèn)); button1.setBounds(300,250,70,30);button1.addActionListener(this);add(a1);add(a2);add(text1);add(
5、button1);setBackground(Color.lightGray);setBounds(100,100,600,400);setVisible(true);validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e) System.exit(0););public static void main(String args) (ZuCheng z1=new ZuCheng(計(jì)算機(jī)組成原理); ) public void actionPerformed(ActionEve
6、nt e) (String s=new String(123);if(e.getSource()=button1) (while(i=0&m3) JOptionPane.showMessageDialog(this,您已被禁用,錯(cuò)誤對(duì)話框 ”,JOptionPane.ERROR_MESSAGE);)if(i=1)if(e.getSource()=m1) (Show s1=new Show(機(jī)器數(shù)表示); sl.setVisible(true);)else if(e.getSource()=m2)(Form3 f1=new Form3();f1.setTitle(定點(diǎn)變形補(bǔ)碼加減);f1.set
7、Visible(true);)else if(e.getSource()=m3)(Form4 f2=new Form4();f2.setTitle(定點(diǎn)原碼乘法); f2.setVisible(true);)else if(e.getSource()=m4) (Form5 f5=new Form5(浮點(diǎn)力口減); f5.setVisible(true);)else if(e.getSource()=m5)(Help h1=new Help(幫助信息); h1.setVisible(true);h1.work();)package src;import java.awt.*;import jav
8、a.awt.event.*;public class Show extends Frame implements ActionListener (int me=0;Label b1,b2,b3;Font f;TextField t1,t2;Button button1,button2,button3,button4,button5,button6;Show(String s) (super(s);setLayout(null);f=new Font(黑體,Font.BOLD,20);b1=new Label(定點(diǎn)整數(shù)的機(jī)器表示);b2=new Label(請(qǐng)輸入一個(gè)二進(jìn)制數(shù):);b3=new
9、Label(該數(shù)對(duì)應(yīng)的原碼為:);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=new TextField(15);t2=new TextField(15);t1.setBounds(250,200,200,25);t2.setBounds(250,250,200
10、,25);button1=new Button(輸入);button2=new Button(原碼);button3=new Button(反碼);button4=new Button(補(bǔ)碼);button5=new Button(移碼);button6=new Button(返回);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,
11、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.addActionLis
12、tener(this);button4.addActionListener(this);button5.addActionListener(this);button6.addActionListener(this);validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e) setVisible(false););public void actionPerformed(ActionEvent e)if(e.getSource()=button1) me=1;t1.request
13、FocusInWindow(); else if(me=1) (if(e.getSource()=button2) (String si =t1.getText().trim();int x =Integer.valueOf(s1,2);if(x0)StringBuffer s22=new StringBuffer(s1);s22.setCharAt(0, 0);t2.setText(s22.toString(); else if(e.getSource()=button3) String s =t1.getText().trim();int x =Integer.valueOf(s, 2);
14、 int t=s.length()-1;if(x0)StringBuffer s1 = new StringBuffer(s);s1.deleteCharAt(0);StringBuffer s2 = new StringBuffer(t1.getText().trim();s2.deleteCharAt(0);for(int i=0;i0)StringBuffer si = new StringBuffer(s);sl.deleteCharAt(O);String s11=s1.toString();t2.setText(0+s11);else if(e.getSource()=button
15、4) String s =t1.getText().trim();int x =Integer.valueOf(s, 2);int t=s.length()-1;String sub=1;int sub1=Integer.valueOf(sub, 2);if(x0)StringBuffer s1 = new StringBuffer(s);s1.deleteCharAt(0);StringBuffer s2 = new StringBuffer(t1.getText().trim();s2.deleteCharAt(0);for(int i=0;i0)StringBuffer s1 = new
16、 StringBuffer(s);s1.deleteCharAt(0);String s11=s1.toString(); t2.setText(0+s11);else if(e.getSource()=button5) String s1 =t1.getText().trim();int x= Integer.valueOf(s1,2); if(x0;i-)s12.setCharAt(i, s12.charAt(i-1); s12.setCharAt(0, a);String shuchu =s12.toString();t2.setText(1+shuchu);else if(x0)Str
17、ingBuffer s12 =new StringBuffer(s1);s12.deleteCharAt(0);int l=s12.length()-1;char a=s12.charAt(l);for(int i=l;i0;i-)s12.setCharAt(i, s12.charAt(i-1);s12.setCharAt(0, a);String shuchu =s12.toString();t2.setText(0+shuchu);else if(e.getSource()=button6)setVisible(false);package src;import java.awt.*;im
18、port java.awt.event.*;public class Form3 extends Frame implements ActionListener Font f; int me1=0; String ss1,ss2; int r;Label l1,l2,l3,l4,l5;TextField d1,d2,d3,d4;Button bu1,bu2,bu3,bu4;Form3()(setLayout(null););f=new Font(黑體,Font.BOLD,20);l1=new Label(定點(diǎn)整數(shù)的變形補(bǔ)碼加減運(yùn)算l2=new Label(請(qǐng)輸入第一個(gè)數(shù):);l3=new La
19、bel(請(qǐng)輸入第二個(gè)數(shù):);l4=new Label(加法結(jié)果:);l5=new Label(減法結(jié)果:);l1.setBackground(Color.pink);l1.setFont(f);l2.setBackground(Color.gray);l3.setBackground(Color.gray);l4.setBackground(Color.gray);l5.setBackground(Color.gray);d1=new TextField(20);d2=new TextField(20);d3=new TextField(20);d4=new TextField(20);bu1
20、=new Button(輸入);bu2=new Button(力口法);bu3=new Button(減法);bu4=new Button(返回);l1.setBounds(150,100,250,40);l2.setBounds(100,180,120,25);l3.setBounds(100,210,120,25);l4.setBounds(100,240,120,25);l5.setBounds(100,270,120,25);d1.setBounds(250, 180,200,25);d2.setBounds(250, 210,200,25);d3.setBounds(250, 240
21、,200,25);d4.setBounds(250, 270,200,25);bu1.setBounds(80,350,70,25);bu2.setBounds(170,350,70,25);bu3.setBounds(260,350,70,25);bu4.setBounds(350,350,70,25);add(l1);add(l2);add(l3);add(l4);add(l5);add(d1);add(d2);add(d3);add(d4);add(bu1);add(bu2);add(bu3);add(bu4);bu1.addActionListener(this);bu2.addAct
22、ionListener(this);bu3.addActionListener(this);bu4.addActionListener(this);setBounds(100,100,600,400);setBackground(Color.lightGray);validate();addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e) setVisible(false););public String work1() String sg=d1.getText();System.out.pri
23、nt( sdf);if(sg.startsWith(+) int index=sg.indexOf(+);String ss=sg.substring(index+1);ss1=ss.replaceFirst(0, 00);/ 獲得第一個(gè)數(shù)的補(bǔ)碼(+) elseint index=sg.indexOf(-);String ss=sg.substring(index+1);char a=ss.toCharArray();for(int i=0;i=2;j-)if(aj-1=0)aj-1=1;aj=0;break;elseaj=0;String se=new String(a);ss1=se.re
24、placeFirst(0, 11);/ 獲得第一個(gè)數(shù)的補(bǔ)碼(一) )return ss1;) public String work2()String sa=d2.getText();if(sa.startsWith(+) int index=sa.indexOf(+);String ss=sa.substring(index+1);ss2=ss.replaceFirst(0, 00);/ 獲得第二個(gè)數(shù)的補(bǔ)碼(+) elseint index=sa.indexOf(-);String ss=sa.substring(index+1);char b=ss.toCharArray();for(int
25、 i=0;i=2;j-)if(bj-1=0)bj-1=1;bj=0;break;elsebj=0;String sc=new String(b);ss2=sc.replaceFirst(0, 11);/ 獲得第二個(gè)數(shù)的補(bǔ)碼()return ss2; public String work3() String sa=d2.getText();if(sa.startsWith(-) int index=sa.indexOf(-);String ss=sa.substring(index+1);ss2=ss.replaceFirst(0, 00);/ 獲得第二個(gè)數(shù)的補(bǔ)碼(+) elseint inde
26、x=sa.indexOf(+);String ss=sa.substring(index+1);char b=ss.toCharArray();for(int i=0;i=2;j-)if(bj-1=0)bj-1=1;bj=0;break;elsebj=0;Stringsc=new String(b);ss2=sc.replaceFirst(0, 11);/ 獲得第二個(gè)數(shù)的補(bǔ)碼()return ss2;public String add1(char a1,char a2) (char jg=new charr;char cf=0;while(r0)(if(a1r-1=0&a2r-1=0&cf=0
27、)jgr-1=0;cf=0;else if(a1r-1=0&a2r-1=0&cf=1)|(a1r-1=0&a2r-1=1&cf=0)|(a1r-1=1&a2r-1=0&cf=0)jgr-1=1;cf=0;else if(a1r-1=0&a2r-1=1&cf=1)|(a1r-1=1&a2r-1=0&cf=1)|(a1r-1=1&a2r-1=1&cf=0) jgr-1=0;cf=1;else if(a1r-1=1&a2r-1=1&cf=1)jgr-1=1;cf=1;else jgr-1=a1r-1;r-;String result=new String(jg);return result;publ
28、ic void actionPerformed(ActionEvent e )if(e.getSource()=bu1)me1=1;d1.requestFocusInWindow();d2.requestFocusInWindow();else if(me1=1)if(e.getSource()=bu2) String s1=work1();String s2=work2();if(s1.length()s2.length()r=s1.length();else r=s2.length();char c=new charr;char d=new charr;s1.getChars(0, s1.
29、length(), c, 0);s2.getChars(0, s2.length(), d, 0);String cd=this.add1(c, d);d3.setText(cd);)else if(e.getSource()=bu3)(String s1=work1();String s2=work3();if(s1.length()s2.length()r=s1.length();else r=s2.length();char c=new charr;System.out.print( sdf);char d=new charr;System.out.print( sdf);s1.getC
30、hars(0, s1.length(), c, 0);s2.getChars(0, s2.length(), d, 0);String cd=this.add1(c, d);d4.setText(cd);)else if(e.getSource()=bu4)(setVisible(false);)package src;import java.awt.*;import javax.swing.*;import src.ZuCheng;import java.awt.event.*;public class Form4 extends Frame implements ActionListene
31、r Box basebox, box1, box2, box3, box4, box5;Button b1, b2, b3;Label name, input, input1, input2;TextField data, datal, data2;public Form4() setTitle(定點(diǎn)整數(shù)的原碼乘法);setBounds(200, 300, 500, 300);b1 = new Button(輸入);b2 = new Button(乘法);b3 = new Button(返回);box1 = Box.createHorizontalBox();name = new Label(
32、定點(diǎn)整數(shù)的原碼乘法 , Label.CENTER);box1.add(name);box2 = Box.createHorizontalBox();input = new Label(請(qǐng)輸入被乘數(shù)(一位符號(hào)位):);data = new TextField(10);box2.add(input);box2.add(data);box3 = Box.createHorizontalBox();input1 = new Label(請(qǐng)輸入乘數(shù)(一位符號(hào)位):);data1 = new TextField(9);box3.add(input1);box3.add(data1);box4 = Box.
33、createHorizontalBox();input2 = new Label(乘法結(jié)果為(一位符號(hào)位):);data2 = new TextField(12);box4.add(input2);box4.add(data2);box5 = Box.createHorizontalBox();box5.add(b1);box5.add(b2);box5.add(b3);basebox = Box.createVerticalBox();basebox.add(box1);basebox.add(Box.createVerticalStrut(20);basebox.add(box2);bas
34、ebox.add(Box.createVerticalStrut(20);basebox.add(box3);basebox.add(Box.createVerticalStrut(20);basebox.add(box4);basebox.add(Box.createVerticalStrut(20);basebox.add(box5);setLayout(new FlowLayout();add(basebox);b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);setVisib
35、le(true);addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) setVisible(false););validate();Overridepublic void actionPerformed(ActionEvent e) if (e.getSource() = b1) / 輸入開關(guān)data.setText(null);data1.setText(null);data2.setText(null);data.requestFocusInWindow();else if (e.ge
36、tSource() = b2) String s1 = data.getText();String s2 = data1.getText();StringBuffer fuhao1 =new StringBuffer(s1);StringBuffer fuhao2 =new StringBuffer(s2);int x=Integer.valueOf(s1,2);int y =Integer.valueOf(s2, 2);if(x0&y0)/*|(fuhao1.charAt(0)=1&fuhao2.charAt(0)=1)*/)StringBuffer s11 = new StringBuff
37、er(s1);StringBuffer s21 =new StringBuffer(s2);s11.deleteCharAt(0);s21.deleteCharAt(0);si =s11.toString();s2=s21.toString();int x1 =Integer.valueOf(s1,2);int x2 =Integer.valueOf(s2, 2);int sub =x1*x2;String sub1 =Integer.toBinaryString(sub);data2.setText(subi);else if(x0)/*|(fuhao1.charAt(0)=1&fuhao2
38、.charAt(0)=0)*/)StringBuffer s11 = new StringBuffer(s1);StringBuffer s21 =new StringBuffer(s2);s11.deleteCharAt(0);s21.deleteCharAt(0);s1 =s11.toString();s2=s21.toString();int x1 =Integer.valueOf(s1,2);int x2 =Integer.valueOf(s2, 2);int sub =x1*x2;String sub1 =Integer.toBinaryString(sub);data2.setText(sub1);else if(x0&y0&y0)/*|(fuhao1.charAt(0)=0&fuhao2.charAt(0)=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 草皮搬運(yùn)合同范本
- Koenine-生命科學(xué)試劑-MCE
- Bengamide-B-生命科學(xué)試劑-MCE
- 新增工程補(bǔ)充合同范本
- 電力工程承包合同范本14篇
- 2025年畜禽肉、油脂及食用雜碎合作協(xié)議書
- 2025年光纖用GECL4項(xiàng)目合作計(jì)劃書
- 設(shè)計(jì)責(zé)任與賠償合同(2篇)
- 2025年工業(yè)索類合作協(xié)議書
- 教師經(jīng)驗(yàn)報(bào)告范文
- 三一重工全面預(yù)算管理
- 小公司財(cái)務(wù)報(bào)銷制度及報(bào)銷流程
- 《環(huán)境感知技術(shù)》2024年課程標(biāo)準(zhǔn)(含課程思政設(shè)計(jì))
- 礦山用電安全培訓(xùn)課件
- 2025年中考語文一輪復(fù)習(xí):八年級(jí)上冊(cè)知識(shí)點(diǎn)梳理
- 航空物流運(yùn)輸服務(wù)標(biāo)準(zhǔn)
- 運(yùn)用HFMEA品管工具優(yōu)化輸血全流程醫(yī)院品質(zhì)管理案例(血液科輸血科信息科醫(yī)務(wù)科護(hù)理部)
- 《EEG信號(hào)特征提取及腦卒中分類預(yù)測(cè)研究》
- 醫(yī)療設(shè)備維保投標(biāo)方案(技術(shù)方案)
- 非甾體抗炎藥圍術(shù)期鎮(zhèn)痛專家共識(shí)(2024 版)解讀
- 寧德新能源verify測(cè)試題庫
評(píng)論
0/150
提交評(píng)論