![網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/6/2405ca8c-bc77-44c7-9be7-8f290f4987ce/2405ca8c-bc77-44c7-9be7-8f290f4987ce1.gif)
![網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/6/2405ca8c-bc77-44c7-9be7-8f290f4987ce/2405ca8c-bc77-44c7-9be7-8f290f4987ce2.gif)
![網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/6/2405ca8c-bc77-44c7-9be7-8f290f4987ce/2405ca8c-bc77-44c7-9be7-8f290f4987ce3.gif)
![網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/6/2405ca8c-bc77-44c7-9be7-8f290f4987ce/2405ca8c-bc77-44c7-9be7-8f290f4987ce4.gif)
![網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2021-12/6/2405ca8c-bc77-44c7-9be7-8f290f4987ce/2405ca8c-bc77-44c7-9be7-8f290f4987ce5.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、網(wǎng)絡(luò)編程課程實(shí)訓(xùn)報(bào)告口期2008.12.8 2008.12.12地點(diǎn)科 技樓 108機(jī) 房項(xiàng)廿名稱網(wǎng)絡(luò)編程課程設(shè)計(jì)實(shí)訓(xùn)口的 能力目標(biāo)在學(xué)生具備了 java而向?qū)﹀杈幊滔嚓P(guān)知識(shí)與技術(shù)、掌握了 java相關(guān)平臺(tái)技術(shù)的基礎(chǔ)上,著重培養(yǎng)學(xué)生的實(shí)際應(yīng)用能力、分 析問(wèn)題與解決問(wèn)題的能力以及創(chuàng)新能力,增強(qiáng)學(xué)生對(duì)java語(yǔ)言和 java編程工具的熟悉掌握程度,為今后進(jìn)一步深入學(xué)習(xí)java語(yǔ)言 打下一個(gè)堅(jiān)實(shí)的基礎(chǔ)。實(shí)訓(xùn)要求:1、實(shí)訓(xùn)期間嚴(yán)格考勤,考勤作為實(shí)訓(xùn)成績(jī)的一部分。2、實(shí)訓(xùn)期間不能玩游戲、看電影、小說(shuō)等做與學(xué)習(xí)無(wú)關(guān)的事。如果冇不遵 守的同學(xué)將取消當(dāng)天成績(jī)。3、每天的作業(yè)必須經(jīng)過(guò)指導(dǎo)教師檢查后才可以登錄當(dāng)天
2、成績(jī)。4、完成整個(gè)實(shí)訓(xùn)以后,要求每人寫(xiě)出實(shí)訓(xùn)報(bào)告。作為評(píng)定整個(gè)實(shí)訓(xùn)成績(jī)的 重要參考依據(jù)。實(shí)訓(xùn)內(nèi)容(過(guò)程及步驟)第一天1、編程實(shí)現(xiàn)1! +2! +3!+.+10!的結(jié)果并輸出結(jié)果。class sumstatic int jiechengx(int x)int i3sum=1;for(i=1 ;i<=x;i+)sum=sum*i;return sum;public static void main (string args)int i=1,sumall=0;while(i<=10)sumall=sumall+jiechengx(i);i+;system.out.println(n1 !
3、 +2! +3!+.+10!=”+sumall);運(yùn)行結(jié)果:3、用三種循環(huán)實(shí)現(xiàn)輸出0100之間能被3整除的偶數(shù)的值以及偶數(shù)的個(gè)數(shù)。廣public class xunhuanpublic static void main(string args) int i=0,mj=0;while(i<=100)m=i%6;i+;if(m=0)j+;system.out.println(i+ ” ”);system.out.print(nnh);system.out.pri ntln(j);*/*public class xunhuanpublic static void main (string ar
4、gs)int i=0,m,j=0;for(:i<=100;i+)m=i%6;if(m=o)j+;system.out.print(i +” ”);system.out.print(hnh);system.out.pri ntln(j);*/class xunhuanpublic static void main(string args)int i=0,mj=0;dom=i%6;i+;if(m=0)j+;system.ouf.println(i+” ”);while(i<=100);system.ot/?.pri ntln(j);運(yùn)行結(jié)果:4、輸出乘法口訣表public class
5、chengfabiaopublic static void main(string args)int i,j;for(i=1 ;iv=9;i+)for(j=1:j<=9;j+)system.out.println(i+,*,'+j+"=,+i*j+" ”);system.out.pri ntln();運(yùn)行結(jié)杲:5、從鍵盤(pán)讀入一個(gè)數(shù)字,判斷該數(shù)是否為索數(shù):判斷素?cái)?shù)的方法:用一個(gè)數(shù)分別去除2到sqrt(這個(gè)數(shù)),如果能被整除,則 表明此數(shù)不是素?cái)?shù),反z是素?cái)?shù)。import java.io.*;public class sushu public static voi
6、d main(string args)string str=null;int c=0,i=0;boolean isprime=false;bufferedreader streami = new bufferedreader(new inputstreamreader(system./n);trystr=streami.readli ne();catch (loexception ex)tryc=lnteger.parse/n?(str);int sc=(int)math.sq/t(c);for (i = 2; iv=sc; i+)if(c%i=o) break;if (i>sc) is
7、prime=true;catch (numberformatexception ex) system. ex/7(0);if(isprime)system.ot/f.println (c+"是素?cái)?shù)”);elsesystem.ot/f.println (c+"不是素?cái)?shù)”);運(yùn)行結(jié)果:6、編寫(xiě)圖形界而程序,輸入三個(gè)數(shù)x,y,z (從文本框屮輸入),可以將這三 個(gè)數(shù)由小到大或從大到小排序后顯示。import java.awt.*;import java.applet.*;import java.awt.eve nt.*;public class example6 extends
8、applet implements actionlistenerlabel 11,12,13,14,15,16;textfield textl ,text2,text3,text4,text55text6;button button 1;public void init()i1=new labelfx:n);i2=new labelfy:h); i3=new labelfz; );i4=new label(h1:n); i5=new labelc'2:m);i6=new label(”3:”);textl =new textfield(io); text2=new textfield(
9、io); text3=new textfield(io); text4=new textfield(io); text5=new textfield(io); text6=new textfield(io); add(h);add(text1); add(l2);add(text2); add(l3);add(text3);button 1=new button"排序”); add(buttonl); add(l4);add(text4); add(l5);add(text5); add(l6);add(text6);butt on1 .addactionlistener(this)
10、;public void actionperformed(actionevent j)tryif(j.getsource()=button1)double temp;double n1,n2,n3;n1= double./?刃sedoub/e(text1 .gettext();n2=double.parse£?oub/e(text2.gettext();n3=double.parsedoi/dte(text3.gettext();if(n1<n2)temp=n1 ;n1 =n 2;n2=temp;if(n1<n3)temp=n1 ;n1 =n 3;n3=temp;if(n
11、2<n3)temp=n2;n2=n 3;n3=temp; text4.sett ext(string. valueof(n 1): text5.settext(string.ua/i/eo/(n2); text6.settext(string.ua/ueo/(n3);catch(exception e)運(yùn)行結(jié)果:7、請(qǐng)編寫(xiě)一個(gè)applet,其中包含兩個(gè)標(biāo)簽(一個(gè)用于給岀捉示信息,另一 個(gè)用來(lái)輸出結(jié)果)和一個(gè)文本框。耍求從文本框中獲取用戶給岀的一個(gè)整數(shù),并 將該數(shù)的平方和立方在標(biāo)簽上輸出。import java.awt.*;import java.applet.*;import java.
12、awt.eve nt.*;public class example7 extends applet implements action listenerlabel 11,12;textfield text;public void init()i1=new labelf請(qǐng)輸入一個(gè)整數(shù):”);i2=new label();text=new textfield(io);add(h);add (text);add(l2);text.addacti on listener(this);public void actionperformed(action event t) double n,n1,n2;t
13、ryif(t.getsource()=text)n=double.parsedoud/e(text.gettext();n 1=n*n;n 2=n*n*n;l2.settext(”平方:"+string. valueof()+"立方,+string.va/ueof(n2);catch(exception e)運(yùn)行結(jié)果:8、這是一個(gè)偵探題,一輛汽車撞人后逃跑。4個(gè)目擊證人提供如下線索。甲:牌照三、四位相同;乙:牌照為31xxxx;丙:牌照五、六位相同;t:三六位是一個(gè)整數(shù)的平方求牌照號(hào)。public class example8public static void main
14、(string args)int a,b,c,d,i,k;for(i=0;i<=9999;i+)a=i/1000;b=i/100-a*10;c=i/10-a*100-b*10;d=i%10;for(k=1 ;k<100;k+)if(a=b&&c=d&&i=k*k)system. os.print(” 牌號(hào)是 *3f+a+b+c+d);運(yùn)行結(jié)果:第二天:1、創(chuàng)建一個(gè)接口,表示一個(gè)圖形in terface shape 要求1)接i i中包含求解圖形面積和周長(zhǎng)的抽象方法。2)設(shè)計(jì)類square (矩形),triangle (三角形),circle (圓)實(shí)
15、現(xiàn)shape 接口。3) 在2)中設(shè)計(jì)的類中,要求根據(jù)各自的特點(diǎn),設(shè)計(jì)類成員變量,構(gòu)造方法4) 設(shè)計(jì)類class ex3_2 ,在該類屮包含主方法,該方法創(chuàng)建2)屮各個(gè)類 的對(duì)象,并計(jì)算各種圖形的面積,周長(zhǎng)并輸出。附:計(jì)算三角形面積的海倫公式:計(jì)算三角形面積的(a, b, c為三角形的三邊長(zhǎng))sqrt(s*(s-a)*(s-b)*(s-c)s=(a+b+c)/2interface shapevoid area();void circum();長(zhǎng)方形類class square implements shapedouble height,width;public square(double hig
16、h,double width)this.height=height;this.width=width;public void area()system.ouf.println ("square area="+height*width);public void circum()system.outprintln ("square circum= m+2*(height+width);三角形類class triangle implements shapedouble a,b5c;public triangle(double a,double b,double c)th
17、is.a=a;this.b=b;this.c=c;public void area()double s;s=(a+b+c)/2;system.oc/tprintln ("triangle area="+math.sqrt(s*(s-a)*(s-b)*(s-c);public void circum()system.oc/tprintln ("triangle circum= ”+(a+b+c);/圓形類class circle implements shapedouble r;public circle(double r)this.r=r;public void
18、area()system.outprintln ("circle area="+r*r*3.1416 );public void circum()system.outprintln (”circle circum= m+2*3.1416*r);定義公有類class two1square s=new square(4,8);s.area();s.circum();triangle t=new triangle(3,4,5);t.area();t.circum();circle c=new circle(1o);c.area();c.circum();運(yùn)行結(jié)果:2、現(xiàn)有下面的字
19、符串:string s1=”jacket”;string s2=,valm;string s3=”is”;string s4=”l an a good studenf;使用字符串相關(guān)的操作的(例如charat, substring, concat等操作) 從上述字符串中提取出需要的字符串,拼湊htjava is good”字符串并輸出。public class two2string s1-jacket”;string s2=,valh;string s3=”is”;string s4=nl an a good student"string s=s1 .substring(0,2);s
20、=s.concat(s2.substri ng(0,2);s=s.concat(n n);s=s.concat(s3);s=s.c on cat(s4.substri ng(6,11);system.ouf.println (s);運(yùn)行結(jié)果:3、創(chuàng)建一個(gè)整型數(shù)組a20,使用java*!1的隨機(jī)數(shù)函數(shù)給數(shù)組a20賦值, 要求數(shù)組元索取值在0100之間。然后采用適當(dāng)?shù)呐判蛩惴ㄅ判?,輸出。import java.math.*;import java.util.*;public class two3 public static void main(string args)int a=new int20
21、;for (int i = 0; i<20; i+)ai=(int)(math.randon?()*100);system.ot/f.println ("隨機(jī)賦值:”);冒泡法排序for (int i = 0; i<20; i+)system.ouf.print (ai+"t");for (int j = 0; j<a.length-1; j+)for (int k = 0; k<a.length-j-1; k+)if(ak>ak+1)int t=ak;ak=ak+1;ak+1=t;system.ouf.println (hn 排序:
22、”); for (int i = 0; i<20; i+)system.outprint (ai+hth);運(yùn)行結(jié)杲:第三天:熟悉applet程序設(shè)計(jì),重點(diǎn)掌握applet生命周期屮的各個(gè)方法的調(diào)用順序, 掌握齊種圖形界面元素的設(shè)計(jì)和輸出。1、便鞋一個(gè)applet程序:畫(huà)圖要求:界面上有2個(gè)按鈕,一個(gè)為標(biāo)簽為“橢 圓”,另一個(gè)為“矩形”,點(diǎn)擊后分別畫(huà)紅色的橢圓和藍(lán)色的矩形,其寬度為100、 高度為60,左上角頂點(diǎn)坐標(biāo)為(50,50),試寫(xiě)出完整程序,并且要寫(xiě)出其對(duì)應(yīng) 的html文件代碼。import java.awt.*;import java.awt.eve nt.*;import j
23、ava.applet.*;public class threel extends applet implements action listenerbutton button1,button2;label labell ,label2;public void init()labell =new label(h橢圓”);iabel2=new label(”矩形”);button 1=new button(,h);button2=new button(,h);add(label1 );add(button1);add(label2);add(button2);butt on1 .addaction
24、listener(this);button2.addactionlistener(this);public void actionperformed(acti on event j)if(j.getsource()=butt on1) picture1();else if(j.getsource()=butt on2) picture2();repaint();boolean choose;public void picture1()choose=true;public void picture2()choose=false;public void paint(graphics g)int x
25、=50,y=50;if (choose)g.drawoval(50,50,100,60);g.setcolor(color.red);g.filloval(50,50,100,60);elseg.setcolor(color.b/_l/e);g.drawrect(50,50,60,60);g.fillrect(50,50,60,60);運(yùn)行結(jié)果:2、編寫(xiě)一個(gè)計(jì)算器程序,至少冇加減乘除,清零功能,當(dāng)作applet運(yùn)行, 要求數(shù)字是從數(shù)字鍵盤(pán)上輸入(如windows自帶的計(jì)算器)。import java.awt.*;import java.awt.eve nt.*;import java.appl
26、et.*;public class three2 extends applet implements actionlistenerlabel labell ,label2,label3;textfield textl ,text2,text3;button button1,button25button3,button4,button5;public void init()labell =new label(”操作數(shù)”);iabel2=new label(”被操作數(shù)”);iabel3=new label(h結(jié)果”);text1=new textfield(io);text2=new textfi
27、eld(io);text3=new textfield(io);add(label1);add(text1);add(label2);add(text2);add(label3);add(tex t3);button1=new button(”加”);button2=new button(*減”);button3=new button(”乘”);button4=new button(”除”);button5=new button空”);add(button1);add(button2);add(button3);add(button4);add(button5);butt ord .addac
28、tionlistener(this);butt on 2.addactionliste ner(this);butt on 3.addactionlistener(this);butt on4 .addactionliste ner(this);butt on 5.addactionlistener(this);public void actionperformed(actionevent j)double n;tryif(j.getsource()=button1)double n 1n1 = double.parsedoi/dte(text1 .gettext(); n2=double.p
29、arsedoub/e(text2.gettext(); n=n1+n2;text3.sett ext(string. va/t/eo/(n);if(j.getsource()=bu 社0 n2)double n 1n1 = double.parsedoi/dte(text1 .gettext();n2=double.parsedoub/e(text2.gett ext();n=n1-n2;t ext3. settext (s t r i n g. va/t/eo/( n);if(j.getsource()=bu 社 o n3)double n 1n1 = double.parsedoi/dte
30、(text1 .gettext(); n2=double.parsedoub/e(text2.gettext(); n=n1*n2;text3.sett ext(string. va/t/eo/(n);if(j.getsource()=button4)double n 1 j2;n1 = double.parsedoi/dte(text1 .gettext();n2=double.parsedoub/e(text2.gettext();n=n1/n2;text3. sett ext (st r i n g. valueof( n);if(j.getsource()=bu 社。n5)textl.
31、settext(null);text2.settext(null);text3.settext(null);catch(exception e)運(yùn)行結(jié)果:第四天練習(xí)題:根據(jù)所學(xué)java知識(shí),自行設(shè)計(jì)開(kāi)發(fā)一系統(tǒng)。如:記事木、齊種小游戲、員工信息管理系統(tǒng)、學(xué)生成績(jī)杳詢系統(tǒng)等。我的記事本:import java.io.*;import java.awt.*;import java.awt.eve nt.*;public class jishiben extends frame private frame frame=null;private panel contentpane=null;privat
32、e panel panel = null;private butt on button = n ull;private butt on butt on1 = n ull;private butt on button2 = n ull;private scrollpane scrollpane = null;private textarea textarea = null;private filedialog filedialog = null;private boolean haschanged = false;private static final string title = "
33、;simple awt text editor"public static void main(string args) jishiben app = new jishiben();app.show();public jishiben() frame=this;butt on = new button();button.setlabel("load file");butt on .addactionlistener(new java.awt.event.acti on liste ner() public void actionperformed(java.awt
34、.event.actionevent e) loadfile(););button1 = new button();button 1 .setlabel(nsave file");button1 .addactionlistener(new java.awt.event.actionlistener() public void action performed(java.awt.event. action event e) savefile(););button2 = new button();button2.setlabel(hexith);butt on 2.addactionl
35、istener(new java.awt.event.acti on listener() public void actionperformed(java.awt.event.actionevent e) doexit(););panel = new panel();panel.add(button, null);panel.add(button1, null);panel.add(button2, null);textarea = new textarea();textarea.addkeylistener(new java.awt.event.keyadapter() public vo
36、id keytyped(java.awt.event.keyevent e) if (ihaschanged) frame.settitle(title + ” *");haschanged = true;);scrollpane = new scrollpane();scrollpa ne. add (text area);filedialog = new filedialog(frame);frame.setsize(480, 284);frame.settitle(title);contentpane=new panel();con tentpane.setlayout(new
37、java.awt.borderlayout();contentpane.add(panel, java.awt.borderlayout.south);contentpane.add(scrollpane, java.awt.borderlayout.center);frame.add(contentpa ne);frame.addwindowlist ener(new windowadapter() public void windowclosing(windowevent e) doexit(););char buffer=new char1024;int length=o;private
38、 void loadfile() filedialog.setmode(filedialog.load);filedialog.show();string f;if (f = filedialog.getfileo) != null) tryreader reader = new filereader(f); textarea.settext(”);while(length = reader.read(buffer) !=-1) textarea.append(new string(buffer,o,length);reader.close();frame.settitle(title);ha
39、schanged = false; catch (filenotfoundexception e1) e1.printstacktrace(); catch (loexception e1) e1.printstacktrace();private void savefile() filedialog.setmode(filedialog.save);filedialog.show();string f;if (f = filedialog.getfileo) != null) trybufferedwriter bw = new bufferedwriter(new filewriter(f
40、);string text=textarea.gettext():bw.write(text);bw.close();frame.settitle(title);haschanged = false; catch (filenotfoundexception e1) e1.printstacktrace(); catch (loexception e1) e1.printstacktrace();private questiondialog dialog=new questiondialog(this,hsave changes?","file has been chang
41、ed. save before exit?");private void doexit() if (haschanged) dialog.show();int state = dialog.getresult();if (state = questiondialog.yes) savefile(); else if (state = questiondialog.cancel) return;frame.dispose();class questiondialog extends dialog implements actionlistener public static final int yes=1;public static final int no=2;public static final int cancel=3;public static final int running=0;private window pare nt;private int result;public int getresult()return result;private butt on yes=new button(” yes”);private butt on no=new button("noh);p
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023二年級(jí)語(yǔ)文上冊(cè) 第八單元 23 紙船和風(fēng)箏說(shuō)課稿 新人教版
- 2025駕駛員安全生產(chǎn)聘用合同
- 2025X大學(xué)技術(shù)合同管理辦法
- 2025建筑外墻改造工程合同
- Module 9 Unit 1 We laughed a lot(說(shuō)課稿)-2023-2024學(xué)年外研版(三起)英語(yǔ)五年級(jí)下冊(cè)001
- Unit 1 School Subjects Lesson3(說(shuō)課稿)-2023-2024學(xué)年人教新起點(diǎn)版英語(yǔ)三年級(jí)下冊(cè)
- 公司法律事務(wù)代理合同范例
- 2024-2025學(xué)年高中歷史 第三單元 各國(guó)經(jīng)濟(jì)體制的創(chuàng)新和調(diào)整 第14課 社會(huì)主義經(jīng)濟(jì)體制的建立(1)教學(xué)說(shuō)課稿 岳麓版必修2
- Module 2 Unit 1 I helped my mum.(說(shuō)課稿)-2024-2025學(xué)年外研版(一起)英語(yǔ)四年級(jí)上冊(cè)
- 9小水滴的訴說(shuō) 第二課時(shí) 說(shuō)課稿-2023-2024學(xué)年道德與法治二年級(jí)下冊(cè)(統(tǒng)編版)
- 2025南網(wǎng)科研院系統(tǒng)內(nèi)招聘13人易考易錯(cuò)模擬試題(共500題)試卷后附參考答案
- 關(guān)于合同知識(shí)的全面解讀
- Unit 6 Beautiful landscapes Integration 說(shuō)課稿 -2024-2025學(xué)年譯林版英語(yǔ)七年級(jí)下冊(cè)001
- 五四制青島版三年級(jí)數(shù)學(xué)下學(xué)期教學(xué)計(jì)劃
- 2024年常德職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)適應(yīng)性測(cè)試題庫(kù)
- 山東省濟(jì)南市2023-2024學(xué)年高二上學(xué)期期末考試化學(xué)試題 附答案
- 2025 年福建省中考語(yǔ)文試題:作文試題及范文
- 短視頻運(yùn)營(yíng)績(jī)效考核表KPI-企業(yè)管理
- 【譯林】九下英語(yǔ)單詞默寫(xiě)表
- IEC 62368-1標(biāo)準(zhǔn)解讀-中文
- 15J403-1-樓梯欄桿欄板(一)
評(píng)論
0/150
提交評(píng)論