ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:44.14KB ,
资源ID:4599696      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4599696.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java实验考试大纲101.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java实验考试大纲101.docx

1、java实验考试大纲1011. 任意从键盘输入一个0到9999之间的数,判断输入的数是几位数。import javax.swing.JOptionPane; public class Count public static void main(String args) loopNumber(); static void loopNumber() int number=0,d4,d3,d2,d1; String str=JOptionPane.showInputDialog(输入一个0至9999之间的数); number=Integer.parseInt(str); if(number=0&nu

2、mber0) /判断number是4位数的条件 System.out.println(number+是4位数); else if(d4=0&d30) /判断number是3位数的条件 System.out.println(number+是3位数); else if(d2!=0) System.out.println(number+是2位数); else if(d1!=0) System.out.println(number+是1位数); else if(d4=0&d3=0&d2=0&d1=0) System.out.println(number+是1位数); else System.out.p

3、rintf(n%d不在0至9999之间,number); 2. 铁路运货的运费与路程远近及货物的重量有关,设有如下的单位运费:不足100千米,每吨每千米为1.0元100千米以上,不足300千米,每吨每千米为0.9元300千米以上,不足500千米,每吨每千米为0.8元500千米以上,不足1000千米,每吨每千米为0.7元1000千米以上,每吨每千米为0.6元编程:对输入的货物重量和路程,计算相应的运费。import java.util.Scanner; public class expenditure public double getExpenditure(double kilometer,

4、double ton) double ex = 0; if (kilometer = 100 & kilometer = 300 & kilometer = 500 & kilometer = 1000) ex = ton * kilometer * 0.6; return ex; public static void main(String args) double distance,weight; String s1 = null; expenditure e = new expenditure(); System.out.println(请输入路程:); Scanner scan2 =

5、new Scanner(System.in); s1= scan2.nextLine(); distance = Double.parseDouble(s1); String s2 = null; System.out.println(请输入重量:); Scanner t = new Scanner(System.in); s2 = scan2.nextLine(); weight = Double.parseDouble(s2); System.out.println(e.getExpenditure(distance, weight); 运行结果:3. 根据下面的要求实现圆类Circle。

6、 圆类Circle的成员变量:radius表示圆的半径。 圆类Circle的方法成员:Circle():构造方法,将半径置0。Circle(double r):构造方法,创建Circle对象时将半径初始化为r。double getRadius():获得圆的半径值。double getPerimeter():获得圆的周长。void disp():将圆的半径、圆的周长和圆的面积输出到屏幕。import java.util.Scanner;public class Circle private double radius; public Circle() this.radius = 0; publi

7、c Circle(double r) this.radius = r; public double getRadius() return this.radius; public double getPerimeter() return 2 * Math.PI * this.radius; public double getArea() return Math.PI * this.radius * this.radius; public void disp() System.out.println(半径: + getRadius(); System.out.println(周长: + getPe

8、rimeter(); System.out.println(面积: + getArea(); public static void main(String args) String s1 = null;Circle e = new Circle(); System.out.println(请输入半径:); Scanner scan = new Scanner(System.in); s1= scan.nextLine(); e.radius= Double.parseDouble(s1); e.disp(); 运行结果:4、列出两个数m,n之间的所有素数import java.applet.*

9、; import java.awt.*;import java.awt.event.*;public class P extends Applet implements ActionListener Label result,name; TextField in1,in2; Button btn; int a=0,b=0,m,n,p; TextArea anser=new TextArea(5,30); public void init() result=new Label (请输入两个整形数据:); name=new Label (姓名 :阿力木江 学号:2010101576); in1=n

10、ew TextField(5); in2=new TextField(5); btn=new Button (计算); add (name); add (result); add (in1); add (in2); add(btn); add(anser); btn.addActionListener(this); public void actionPerformed(ActionEvent e) int count=0; a=Integer.parseInt(in1.getText(); b=Integer.parseInt(in2.getText(); if(ab) m=a;a=b;b=

11、m; for(n=a;n=b;n+) for(p=2;p=n;p+) if(n%p=0) break; if(n=p) anser.append( +n+ ); count+=1; if(count%10=0) anser.append(n ); 运行结果:5.使用 java.util.Arrays,将Java所有关键字存在一个字符串数组中,判断一个字符串是否是Java关键字。Java所有关键字: abstract,boolean,break,byte,case,catch,char,class, continue,default,do,double,else,extends,false,fi

12、nal,finally,float,for,if, implements,import,instanceof,int,interface,long,native,new,null,package, private,protected,public,return,short,static,super,switch,synchronized,this, throw,throws,transient,true,try,void,volatile,whileimport java.util.Arrays;import java.util.List;public class aa public stat

13、ic void main(String args) String s = abstract,boolean,break,byte,case,catch,char,class, continue,default,do,double,else,extends,false,final,finally,float,for,if, implements,import,instanceof,int,interface,long,native,new,null,package, private,protected,public,return,short,static,super,switch,synchro

14、nized,this, throw,throws,transient,true,try,void,volatile,while; List l = Arrays.asList(s); System.out.println(被查字符串:throws); if(l.contains(throws) System.out.println(是java关键字); else System.out.println(不存在); System.out.println(我的学号:2010101576); 6.找出程序中错误,编译出正确结果;求二维数组的鞍点。鞍点是行中最大,列中最小。代码:public class

15、 Dort public static void main(String args) for (int i=0;imat.length;i+) for (int j=0;jmati.length;j+) System.out.print( +matij); System.out.println(); boolean find = false; int row=0; int max=0; while (!find & rowmat.length) max=0; for (int j=0;jmatrowmax) max = j; boolean yes = true; while (yes & j

16、mat.length) if (j!=row & matjmaxmatrowmax) yes = false; j+; if (yes) find = true; else row+; if (find) System.out.println(The dort: +matrowmax); else System.out.println(The dort: null); public class Dort public static void main(String args) int mat = 1,2,3,4,5,6,7,8,9; for (int i=0;imat.length;i+) f

17、or (int j=0;jmati.length;j+) System.out.print( +matij); System.out.println(); boolean find = false; int row=0; int max=0; while (!find & rowmat.length) max=0; for (int j=0;jmatrowmax) max = j; boolean yes = true; int j=0; while (yes & jmat.length) if (j!=row & matjmax0); System.out.println(); System.out.print(姓名:阿力木江 学号:2010101576);

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

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