Java复习编程题 30(4)

2019-04-21 01:21

{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'){


Java复习编程题 30(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2011年高考虚拟语气练习题库

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: