77范文网 - 专业文章范例文档资料分享平台

Java复习编程题 30(4)

来源:网络收集 时间:2019-04-21 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

{bufup.append(s1.charAt(i)); bufup.append(' ' ); } else {

buflow.append(s1.charAt(i)); buflow.append('' ); } }

System.out.println(\

System.out.println(\System.out.println(\} } 3.

public class prin_b

{ public static void main(String args[]) {

String s1=\String s2=\String s3=\String s4=\String s5=\if(s1.indexOf('b')= =0) System.out.println(s1);

if(s2.indexOf('b')= =0) System.out.println(s2); if(s3.indexOf('b')= =0) System.out.println(s3); if(s4.indexOf('b')= =0) System.out.println(s4); if(s5.indexOf('b')= =0) System.out.println(s5); } } 4.

public class ppp {

public static void main(String args[]) {

String s1=\int num=0;

for (int i=0;i

System.out.print(\if(num= =0)

System.out.println(\

else System.out.println(num); } }

第七章:

1、 编一个应用程序,按行顺序地读取一个可读文件的内容

2、使用对象的串行化机制,使用RandomAccessFile构造一个应用程序能够随机存取文件的记录,可显示、修改记录的内容

3.编写一个程序,从键盘输入一串字符,统计这串字符中英文字母、数字、其他符号的字符数。 4.编写一个程序,从键盘输入一串字符,从屏幕输出并将其存入a.txt文件中。 5.编写一个程序,从键盘输入10个整数,并将这些数据排序后在标准输出上输出。 编程第1题 import java.io.*; public class ReadFile

{ public static void main(String args[]) { String s;

FileInputStream is; InputStreamReader ir; BufferedReader in; try

{ is=new FileInputStream(\ ir=new InputStreamReader(is); in=new BufferedReader(ir); while((s=in.readLine())!=null) System.out.println(\ }

catch(FileNotFoundException e) { System.out.println(\ System.exit(-2); }

catch(IOException e)

{ System.out.println(\ System.exit(-3); } } }

编程第2题

import java.io.*;

class Day implements Serializable { private int year,month,day; public Day() { year=2000; month=9; day=21; }

public Day(int y,int m,int d) { year=y; month=m; day=d; }

public int getYear() { return year;} public int getMonth(){ return month;} public int getDay() { return day;}

public void outPut() { System.out.println(\年\月\日\ }

class Employee implements Serializable { public static final int NAMESIZE=40;

public static final int RECORDSIZE=2*NAMESIZE+8+4*3; private String name; private double salary; private Day hireDay; public Employee(){}

public Employee(String n,double s,Day d) { name=n; salary=s; hireDay=d; }

public void print()

{ System.out.println(name+\ public void raiseSalary(double byPercent) { salary*=1+byPercent/100; } public int hireYear()

{ return hireDay.getYear(); } }

public class ObjectSer

{ public static void main(String args[]) throws IOException,ClassNotFoundException { int i;

Employee[] staff = new Employee[3];

staff[0] = new Employee(\ staff[1] = new Employee(\

staff[2] = new Employee(\ FileOutputStream fo=new FileOutputStream(\ ObjectOutputStream so=new ObjectOutputStream(fo); try

{ for(i=0;i<3;i++) so.writeObject(staff[i]); so.close(); }

catch(IOException e)

{ System.out.println(\ System.exit(1); }

for(i=0;i<3;i++) staff[i]=null;

FileInputStream fi=new FileInputStream(\ ObjectInputStream si= new ObjectInputStream(fi); try {

for(i=0;i<3;i++)

staff[i]=(Employee) si.readObject(); si.close(); }

catch(IOException e)

{ System.out.print(\ System.exit(1); }

for(i=0;i<3;i++) staff[i].print(); } } 3.答: import java.io.*; public class Count{

public static void main(String[] args) {

int x=0,y=0,z=0; int ch; try{

while((ch=System.in.read())!='\\r'){

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库Java复习编程题 30(4)在线全文阅读。

Java复习编程题 30(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/607813.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: