网络编程实验报告docWord文档下载推荐.docx

上传人:b****3 文档编号:14384687 上传时间:2022-10-22 格式:DOCX 页数:54 大小:55.31KB
下载 相关 举报
网络编程实验报告docWord文档下载推荐.docx_第1页
第1页 / 共54页
网络编程实验报告docWord文档下载推荐.docx_第2页
第2页 / 共54页
网络编程实验报告docWord文档下载推荐.docx_第3页
第3页 / 共54页
网络编程实验报告docWord文档下载推荐.docx_第4页
第4页 / 共54页
网络编程实验报告docWord文档下载推荐.docx_第5页
第5页 / 共54页
点击查看更多>>
下载资源
资源描述

网络编程实验报告docWord文档下载推荐.docx

《网络编程实验报告docWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《网络编程实验报告docWord文档下载推荐.docx(54页珍藏版)》请在冰豆网上搜索。

网络编程实验报告docWord文档下载推荐.docx

3、编写使用不同循环结构结构的程序。

实验内容:

publicclassDataTypes

{

publicstaticvoidmain(Stringargs[])

{

byteb=127;

shorts=32767;

inti=2147483647;

longl=9223372036l;

//为什么long表示的数比Int还小?

charc='

c'

;

floatf=1.23F;

doubled=0.9E-3;

booleanbool=true;

System.out.println("

b="

+b);

s="

+s);

i="

+i);

l="

+l);

c="

+c);

f="

+f);

d="

+d);

bool="

+bool);

}

}

///////////////////////////////////////////////////////////////////////////////////////

publicclassTestif

booleanleap;

intyear=2014;

if((year%4==0&

&

year%100!

=0)||(year%400==0))//

System.out.println(year+"

年是闰年"

);

else

年不是闰年"

//方法二///////////////////////////////////////

year=2008;

if(year%4!

=0)

leap=false;

elseif(year%100!

leap=true;

elseif(year%400!

else

if(leap==true)

System.out.println(year+"

//方法三/////////////////////////////////////

year=2050;

if(year%4==0){

if(year%100==0){

if(year%400==0)

leap=true;

else

leap=false;

}

else

leap=false;

}

//使用switch语句/////////////////////////////////////

//1.编写程序用Switch语句实现从键盘上都1,2,3时,屏幕提示不同的信息

importjava.io.*;

classSwitchTest

publicstaticvoidmain(Stringargs[])throwIOException

chara;

Enteranumberfrom1--3:

"

a=(char)System.in.read();

switch(a)

{

case'

1'

:

System.out.println("

winaCar!

break;

case'

2'

pickedthegoat"

3'

gettokeepyour100!

default:

System.out.println("

entry"

//for循环语句

classForTest

publicstaticvoidmain(Stringargs[])throwsIOException

intfahr,cels;

System.out.println("

CelsiusFahrenheit"

for(cels=0;

cels<

=100;

cels+=5)

{

fahr=cels*9/5+32;

System.out.println(cels+"

"

+fahr);

chara;

outer:

//thisisthelablefortheouterloop

for(inti=0;

i<

10;

i++)

for(intj=0;

j<

j++){

a=(char)System.in.read();

if(a=='

b'

breakouter;

continueouter;

//while循环语句////////////////////////////////////////////

classWhileTest

publicstaticvoidmain(String[]args)throwsIOException

charch;

按1/2/3数字可获大奖!

按空格键后回车可退出循环操作"

while((ch=(char)System.in.read())!

='

'

System.in.skip

(2);

//跳过回车键

switch(ch){

case'

恭喜你获得大奖,一辆汽车"

不错呀,你得到一台笔记本电脑"

case'

没白来,你得到一台冰箱"

default:

System.out.println("

真不兴,你没有奖品!

下次再来"

//多重循环

publicclassMul99

publicstaticvoidmain(String[]args)

{inti,j,n=9;

System.out.print("

*|"

for(i=1;

\n-----|"

for(i=1;

---"

System.out.println();

=n;

i++){

System.out.print("

+i+"

|"

for(j=1;

=i;

j++)

+i*j);

实验感想:

实验二面向对象编程试验

通过编程和上机实验理解Java语言是如何体现面向对象编程基本思想,熟悉类的封装方法以及如何创建类和对象,熟悉成员变量和成员方法的特性,熟悉类的继承性和多态性的作用,熟悉包、接口的使用方法,掌握OOP方式进行程序设计的方法。

1、编写程序实现类的定义和使用。

2、编写不同成员和不同成员方法修饰方法的程序。

3、编写体现类的继承性(成员变量、成员方法、成员变量隐藏)的程序和多态性(成员方法重载、构造方法重载)的程序。

4、编写接口的定义和使用的程序。

5、编写包的定义和使用的程序。

实验内容-

1.日期类输出当前日期

publicclassDate

privateintyear,month,day;

//privatestaticthisYear;

publicDate(inty,intm,intd){

this.year=y;

this.month=m;

this.day=d;

publicvoidread(inty,int

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 电力水利

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1