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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

李尊朝java教材作业参考答案new.docx

1、李尊朝java教材作业参考答案new作业参考答案习题一4、如何建立和运行Java程序?首先启动文本编辑器,如记事本、UltraEdit等,编辑程序代码,并以.Java作为文件扩展名保存程序源代码;然后进入dos环境利用javac编译源程序,生成扩展名为.class的字节码文件;再利用命令java运行字节码文件,得到程序的运行结果。在集成开发环境Jbuilder、Eclipse下,可以完成程序的编辑、编译、调试及运行等所有任务。5、public class LikeJava public static void main(String args) System.out.println(“I Li

2、ke Java Very much!”); 习题二5、(1) 45 (2) false (3) 14 (4) 14 (5)6 (6) true (7) 12 9、public class Volume public static void main(String args) double r=0,v=0; r=double.parseDouble(args0); v=4*3.14159/3*r*r*r; /float pi=3.14159f;System.out.println(“球体积为:”+v); 习题三8、public class Factorials public static voi

3、d main(String args) int i, j; long s=0, k; i=1; do /外循环开始 k = 1; j=1; do/内循环开始 k = k * j; /内循环体 j+; while(j=i);/内循环结束 System.out.println(i + != + k); s = s + k; i+; while(i=20); /外循环结束 System.out.println(Total sum= + s); 10、public class Num public static void main(Stringargs) int i,j,k,n; for (n=100

4、;n1000;n+) i=n/100; j=(n-i*100)/10; k=n%10; if (i*i*i+j*j*j+k*k*k=n) System.out.print(n+ ); 习题四5、import java.util.Scanner;class Factorlong fac(int m)if(m=0|m=1)return 1; else return m*fac(m-1); public static void main(String args) int i,n; long sum=0; String s=; Scanner input=new Scanner(System.in);

5、 System.out.print(Please input n: ); n=input.nextInt(); Factor f=new Factor(); for(i=1;i=n;i+) System.out.println(f.fac(i); sum=sum+f.fac(i); s=s+i+!+; System.out.println(s.substring(0,s.length()-1)+=+sum); 习题五2、import java.io.*;public class YangHuiOk public static void main (String args) throws IOE

6、xception int max,a,i,j; char x; System.out.print(请输入杨辉三角要显示的行数: ); x=(char)System.in.read(); max = Integer.parseInt(String.valueOf(x); a=new intmax; /不要忘记初始化数组了 for (i=0;imax;i+) ai=new inti+1; a00=1; for (i=1;imax;i+) ai0=1; aiai.length-1=1; for (j=1;jai.length-1;j+) aij=ai-1j-1+ai-1j; for(i=0;imax

7、;i+) /for(j=0;j=max-i;j+) System.out.print( ); for(j=0;jmax)max=grade; if(grademin)min=grade; System.out.println(学生成绩中最高为:+max+,最低为:+min+,平均分为:+total*1.0/num); bf.close(); catch(FileNotFoundException e) System.out.println(e.toString(); catch(IOException e1) System.out.println(e1.toString(); 习题十一6、im

8、port java.awt.*;import java.awt.event.*;public class ChangeColor extends Frame private Button red=new Button(红); private Button green=new Button(绿); private Button blue=new Button(蓝); private TextField text=new TextField(); public ChangeColor() super(改变颜色); this.setLayout(null); text.setBackground(C

9、olor.WHITE); red.setBounds(25,50,50,20); this.add(red); green.setBounds(125,50,50,20); this.add(green); blue.setBounds(225,50,50,20); this.add(blue); text.setBounds(25,100,250,30); this.add(text); red.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.setBackgroun

10、d(Color.RED); ); green.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.setBackground(Color.GREEN); ); blue.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.setBackground(Color.BLUE); ); addWindowListener(new WindowAdapter()

11、 public void windowClosing(WindowEvent e) System.exit(0); ); setSize(300,200); setVisible(true); public static void main (String args) ChangeColor color=new ChangeColor(); 习题十二5、import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Goods extends JFrame private JComboBox list; p

12、rivate JTextArea info; private String names= 请选择你要查询的商品, A商品, B商品, C商品, D商品, E商品, F商品 ; private String goods= , A商品,北京,¥300, B商品,上海,¥400, C商品,广州,¥500, D商品,长沙,¥600, E商品,武汉,¥700, F商品,天津,¥800 ; public Goods() super(商品信息); Container pane=this.getContentPane(); pane.setLayout(new BorderLayout(); list=new

13、 JComboBox(names); info=new JTextArea(5,20); pane.add(list,BorderLayout.NORTH); pane.add(info,BorderLayout.CENTER); list.addItemListener(new ItemListener() public void itemStateChanged(ItemEvent e) int index=list.getSelectedIndex(); info.setText(商品名:+goodsindex0+n); info.append(产 地:+goodsindex1+n);

14、info.append(价 格:+goodsindex2+n); ); this.setSize(250,300); this.setVisible(true); public static void main (String args) Goods ccc=new Goods(); ccc.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); 习题十三4、import java.awt.*;import javax.swing.JApplet;publ

15、ic class SimpleApplet extends JApplet implements Runnable int j=0; Thread thread; public void init() thread=new Thread(this); thread.start(); public void stop() thread.destroy(); thread=null; public void run() while(true) repaint(); j+; j=j%3; try thread.sleep(4000); catch(InterruptedException e) pu

16、blic void paint(Graphics g) while(true) g.setFont(new Font(黑体,Font.BOLD,24); switch(j) case 0: g.setColor(Color.RED); break; case 1: g.setColor(Color.BLUE); break; case 2: g.setColor(Color.GREEN); g.drawString(各位同学大家好,你们辛苦啦! ,50,60); 习题十四4、public class UseThread extends Thread int st,en,count=0; UseThread(int m,int n) this.st=

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

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