2021年JAVA语言程序设计期末考试试题及答案应考必备题库.doc
2024-05-13 10:49:23 59KB
1
java语言程序设计基础篇课后编程练习答案,提供编程练习个习题的源代码
1
19章ppt,还有些代码及应用,很不错的学习资料,希望对大家有帮助
2024-01-18 09:13:58 10.94MB JAVA
1
java 编写计算器的简单程序//一个较为简洁的巧妙的计算器程序, import java.io.*; import java.awt.event.*; import java.awt.*; //需要解决的问题,数学的运算都有正负号的出现,在点击等号的时候就会有冲突,应该怎样解决,经验:双精度浮点型数据类型是会像后减一位。0.7会显示成0.69999999 public class app74 { static int i=0; static int j=0; static int k=-1; static int l=-1; //static int Data1[]={1}; static String str9=""; static Frame frm1=new Frame("计算器"); static Button btn1=new Button("1"); static Button btn2=new Button("2"); static Button btn3=new Button("3"); static Button btn5=new Button("4"); static Button btn6=new Button("5"); static Button btn7=new Button("6"); static Button btn9=new Button("7"); static Button btn14=new Button("8"); static Button btn16=new Button("9"); static Button btn11=new Button("0");//数字0 static Button btn4=new Button("."); static Button btn8=new Button("+"); static Button btn10=new Button("-"); static Button btn15=new Button("*"); static Button btn13=new Button("/"); static Button btn20=new Button("="); static Button btn18=new Button("清零"); static Button btn19=new Button("后退"); static Button btn12=new Button("π"); static Button btn17=new Button("颜色"); static TextField TF1=new TextField(); static Label Lb1=new Label(".0",Label.RIGHT); //标签 static Label Lb2=new Label(".0",Label.RIGHT); //BS字符长度 static Label Lb3=new Label(".0",Label.RIGHT); //对象str22字符长度 static Label Lb4=new Label(".0",Label.RIGHT); //BS剩余字符长度字符长度 static Label Lb5=new Label("无",Label.LEFT); //执行错误抛出 static Label Lb6=new Label("对象BS字符长度 : ",Label.LEFT); static Label Lb7=new Label("对象str22字符长度 :",Label.LEFT); static Label Lb8=new Label("对象BS剩余字符长度:",Label.LEFT); static Label Lb9=new Label("错误:",Label.LEFT); static Label Lb10=new Label(".0",Label.RIGHT); //计算器下面的标签 static Label Lb11=new Label("余数:",Label.RIGHT); //余数标签 static Label Lb12=new Label(".0",Label.RIGHT); static TextArea TA=new TextArea("说明:由于软件不够完善,请规范运算的输入:1.可在里面按键输入",1000,TextArea.SCROLLBARS_VERTICAL_ONLY); static TextField TF=new TextField(); static GridLayout GL1=new GridLayout(5,4); //流动布局 static Panel Pl=new Panel(); //面板 static BorderLayout BL=new BorderLayout(); static shijian app1=new shijian(); //实现监听器的类对象 static char Data2[]=new char[5]; static Font fnt=new Font("Serief",Font.ITALIC+Font.BOLD,18); static Font fnt2=new Font("Serief",Font.BOLD,15); static String str22; static StringBuffer BS=new StringBuffer(""); //可创建空的字符串对象,这个很重要 static String str23=str22; public static void main(String args[]) throws IOException { frm1.setLayout(null); Pl.setLayout(GL1);//面板加入布局 frm1.setSize(253,450);//没有设置窗口大小 frm1.setLocation(250,450); Lb1.setBounds(0,55,250,25);//计算器数字输入显示框之一上边框 Pl.setBounds(0,80,250,290); Lb2.setBounds(370,60,50,25); Lb3.setBounds(370,90,50,25); Lb4.setBounds(370,120,50,25); Lb5.setBounds(300,150,320,25); Lb6.setBounds(250,60,120,25); Lb7.setBounds(250,90,120,25); Lb8.setBounds(250,120,120,25); Lb9.setBounds(250,150,30,25); Lb10.setBounds(0,365,250,30);//计算器数字输入显示框之一下边框 Lb11.setBounds(250,30,120,25); Lb12.setBounds(370,30,50,25); TF.setBounds(0,30,250,25); TA.setBounds(0,395,250,75); TA.setEditable(false); Pl.add(btn1);//面板 Pl.add(btn2); Pl.add(btn3); Pl.add(btn4); Pl.add(btn5); Pl.add(btn6); Pl.add(btn7); Pl.add(btn8); Pl.add(btn9);//加入按钮 Pl.add(btn14); Pl.add(btn16); Pl.add(btn17); Pl.add(btn10);//加 Pl.add(btn11);//减 Pl.add(btn12);//乘 Pl.add(btn13);//除 Pl.add(btn15);//这里是等号注意事件的监听器在不同的类上 Pl.add(btn17); Pl.add(btn18); Pl.add(btn19); Pl.add(btn20); frm1.add(Pl);//加入面板 frm1.addWindowListener(new shijian2()); frm1.add(Lb1); frm1.add(Lb2); frm1.add(Lb3); frm1.add(Lb4); frm1.add(Lb5); frm1.add(Lb6); frm1.add(Lb7); frm1.add(Lb8); frm1.add(Lb9); frm1.add(Lb10); frm1.add(Lb11); frm1.add(Lb12); frm1.add(TA); frm1.add(TF); //Lb2.setBackground(Color.pink); //Lb3.setBackground(Color.pink); //Lb4.setBackground(Color.pink); //Lb5.setBackground(Color.white); Lb6.setBackground(Color.white); Lb7.setBackground(Color.white); Lb8.setBackground(Color.white); Lb9.setBackground(Color.white); Lb10.setBackground(Color.gray); Lb11.setBackground(Color.white); TF.setBackground(Color.pink); //TA.setBackground(Color.pink); //Lb12.setBackground(Color.gray); Lb1.setFont(fnt); Lb2.setFont(fnt); Lb3.setFont(fnt); Lb4.setFont(fnt); Lb10.setFont(fnt); Lb11.setFont(fnt2); Lb12.setFont(fnt); Lb1.setBackground(Color.gray); btn1.addActionListener(app1); btn2.addActionListener(app1); btn3.addActionListener(app1); btn4.addActionListener(app1); btn5.addActionListener(app1); btn6.addActionListener(app1); btn7.addActionListener(app1); btn8.addActionListener(app1); btn9.addActionListener(app1); btn10.addActionListener(app1); btn11.addActionListener(app1); btn12.addActionListener(app1); //btn12.addActionListener(app1);//写两个这个则会被触发两次事件 btn13.addActionListener(app1); btn14.addActionListener(app1); btn15.addActionListener(app1); btn16.addActionListener(app1); btn17.addActionListener(app1); btn18.addActionListener(app1); btn19.addActionListener(app1); btn20.addActionListener(app1); TF.addTextListener(new shijian3()); frm1.setBackground(Color.white); frm1.setResizable(false); frm1.setVisible(true);//可见 } static class shijian implements ActionListener//接口的实现 { public void actionPerformed(ActionEvent e) { Button BT=(Button)e.getSource(); //取得事件的对象,用于判断事件所属 String str1=BT.getLabel(); //取得按钮的名字,也就是相应的数字 if(str1=="0"||str1=="1"||str1=="2"||str1=="3"||str1=="4"||str1=="5"||str1=="6"||str1=="7"||str1=="8"||str1=="9"||str1=="+"||str1=="-"||str1=="*"||str1=="/"||str1=="."||str1=="π") { if(str1=="π"){str1=Double.toString(Math.PI);} BS.append(str1);//将得到的字符串加入到原有字符串 String str22=BS.toString();//转换成字符串 String str56=Integer.toString(str22.length());//将整形转换成字符串 Lb10.setText(str22); Lb2.setText(str56); Lb3.setText(str56); Lb4.setText(str56); Lb5.setText("无"); Lb12.setText(".0"); Lb1.setText(str22); try{ FileWriter FQ=new FileWriter("D:\\java\\10.txt");FQ.write(str22);FQ.flush();} catch(Exception u) {System.out.println("出错了");}} if(str1=="=")//如果等于等号if里面包含多个if或者while { // System.out.println("str22="+str22); char Data[]=new char[BS.length()]; try{ FileReader FV=new FileReader("D:\\java\\10.txt");//写入所需数据 FV.read(Data);} //这是我们写入的数据, catch(Exception y){System.out.println("出错了");} while(k
2023-12-19 07:02:42 110KB java
1
实现基于P2P的聊天程序,用java语言编写,有界面可以选择不同的用户以及群聊,可以设置字体。
2023-12-10 07:02:17 175KB JAVA 聊天程序 网络应用开发
1
Java语言的经典教材,多年来畅销不衰。本书全面整合了Java 8的特性,采用“基础优先,问题驱动”的教学方式,循序渐进地介绍了程序设计基础、解决问题的方法、面向对象程序设计、图形用户界面设计、异常处理、I/O和递归等内容
2023-12-07 07:03:56 64.96MB Java程序设计
1
基于Java的图书管理系统设计与实现项目是一款图书信息管理软件,该软件基于JAVA技术,提供了图书存储、借阅、归还、馆藏、维护和管理等多种功能,同时具有查询、统计等管理功能, 为图书馆和学校等教育机构等提供了集中、安全、便捷的图书资源管理和服务。 设计此项目的使用人群为图书馆管理员、工作人员、学生和教师等管理和使用图书资源的人群。使用场景包括:图书信息的查询、借阅、归还、续借、预约、统计、馆藏管理等多种场景。此外,该系统适用于中小的学校或者公共图书馆的信息管理,为其提供了一站式、智能化、可扩展的图书信息服务。 此项目的目的是提供一种功能强大、可靠的图书信息管理系统,实现图书信息管理中的自动化和集中化,达到快速、高效的服务效果。为图书馆和教育机构提供高效、多元的图书信息服务是此项目的基本目标。
2023-11-26 16:47:01 893KB java 源码 程序设计
1
记忆测试软件、计算器、Hannoi塔、JPEG图像生成器、标准考试系统(单机版)、标准考试系统(CS网络版)、标准考试系统(BS网络版)、日历记事本、学籍管理系统、图书查询系统(BS网络版)、中国象棋打谱软件、模版游戏、挖雷游戏、网络聊天室(BS模式)、局域网络广播系统java程序源代码
2023-11-25 14:46:35 85KB Java小程序
1
1.欲复制的目录中包含的文件数和子目录层次未知,必须在程序执行时获得这些信息。 2.显示欲复制的目录的相关信息。
2023-11-25 07:02:57 228KB java 应用程序
1
Java 语言程序设计-进阶篇(原书第10版).pdf
2023-11-21 07:01:53 199B java
1