计算机语言Java考试模拟试题附答案.docx

上传人:scccc 文档编号:11882695 上传时间:2021-10-12 格式:DOCX 页数:10 大小:15.12KB
返回 下载 相关 举报
计算机语言Java考试模拟试题附答案.docx_第1页
第1页 / 共10页
计算机语言Java考试模拟试题附答案.docx_第2页
第2页 / 共10页
计算机语言Java考试模拟试题附答案.docx_第3页
第3页 / 共10页
亲,该文档总共10页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《计算机语言Java考试模拟试题附答案.docx》由会员分享,可在线阅读,更多相关《计算机语言Java考试模拟试题附答案.docx(10页珍藏版)》请在三一文库上搜索。

1、计算机语言Java考试模拟试题附答案计算机语言 Java 考试模拟试题附答案1、编写程序,计算以下分段函数的值。x? (x=0)y=-x?(x=0)y 二 x ; elsex;System. out ? printin ( y 二 +y);2、根据年龄,判断某人是否为成年。importjava. io. *;publicclasstestapublicstaticvoidmain(Stringargs)throwsIOExcept i onintx;InputStreamReaderreader=newInputStreamReader(System. in);BufferedReaderin

2、put 二 newBufferedReader(reader);System? out ? printin ( 请车入 x: );Stringtemp 二 input ? readLine();x=Float. parseFloat(temp);if (x=18)System? out ? printin ( 成年人 ); if (xy)m=x; elsem二 y;System, out. printin (,z 最大数为 +m);5、比较两个数的大小,找出其中的最小数并输出。 importjava ? io. *;publicclasskapublicstaticvoidmain(Strin

3、gargs)throwsIOExceptionf loat?x, y, m;m二 0;InputStreamReaderreaderx八newlnputStreamReader(System ? in);BufferedReaderinputx=newBufferedReader(readerx);System? out ? printin ( 请车入 x: );Stringtempx 二 inputx ? readLine();x=Float. parseFloat(tempx);InputStreamReaderreadery八newlnputStreamReader(System ? i

4、n);BufferedReaderinputy 二 newBufferedReader(readery);System ? out ? print ln (z/ iW%5 A y:);Stringtempy 二 inputy. readLine();y=Float ? parseFloat(tempy);if(xm二 x; elsem=y;6、编写一个 Java 程序,判断某年份是否为闰年。 importjava ? io. *;publicclasstestapublicstaticvoidmain(Stringargs)throwsIOExcept i onfloat?x;InputStr

5、eamReaderreader=newInputStreamReader(System. in); BufferedReaderinput=newBufferedReader(reader);System? out ? printin ( 请车入 x: );St:ringtemp 二 input ? readLine();x=Float. parseFloat(temp);if (x0=0)System, out. println (+x+ 是闰年 ) ;else辻(x%4=0)else System. out ? 卩 1?:1111;1.11(+ 乂+不是闰年 );7、比较两个数的大小,找出

6、其中的最大数和最小数并输出。 importjava ? io. *;publicclasska publicstaticvoidmain(Stringargs)throwsIOExceptionfloat?x,y;in);InputStreamReaderreaderx=newInputStreamReader(System ? BufferedReaderinputx=newBufferedReader(readerx);System? out ? printin ( 请车入 x: );Stringtempx= inputx. readLine ();x=Float. parseFloat(

7、tempx); InputStreamReaderreadery=newInputStreamReader(System. in); BufferedReaderinputy 二 newBufferedReader(readery);System? out ? printin ( 请车俞入 y: );Stringtempy=inputy. readLine ();y=Float ? parseFloat(tempy);if(xSystem, out. printin (,z 最大数为 +y); elseSystem, out. printinSystem, out. printin ( 最小数

8、为 +y) ;,z 最大数为 +x);大数8、比较两个数的大小,找岀其中的最大数和最小数,并输出最 和最小数之差。importjava ? io. *;publicclasskapublicstaticvoidmain (Stringargs)throwsIOExceptionf loat?x, y, m;In putStreamReaderreaderx八 newl nputStreamReader(System. i n);BufferedReaderinputx=newBufferedReader(readerx);System? out ? printin ( 请车入 x: );Str

9、ingtempx 二 inputx ? readLine ();x=Float. parseFloat(tempx);In putStreamReaderreadery八 newl nputStreamReader(System. i n);BufferedReaderinputy 二 newBufferedReader(readery);System? out ? println ( ZlW$H5 A y : );Stringtempy=inputy. readLine();y=Float. parseFloattempy;ifxSystem, out. printin最小数为 +x System, out. printin,z 最大数为 +y

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1