java 编程;求解。能帮我改下吗?
package a72;
import java.io.*;
public class a72 {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("输入准考证号码:");
int i;
int l[]=new int[16];
String input1=br.readLine();
l[i]=input1.length();
if(l[i]!=15){
System.out.println("输入错误!准考证号必须15位");
}
if((input1.endsWith("1"))||(input1.endsWith("3"))||(input1.endsWith("5"))||(input1.endsWith("7"))||(input1.endsWith("9")))
System.out.println("考试类别A类");
else System.out.println("考试类别B类");
StringBuffer sb[]=new StringBuffer(input1);
//
sb[i].replace(5,l[i]-4,"******"); //
System.out.println(sb[i]);
}
} 展开
/* package whatever; // don't place package name! */
import java.io.*;
class a72 {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("输入准考证号码:");
String value;
try
{
while((value = br.readLine()) != null)
{
print(value);
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public static void print(String input)
{
if(input.length() != 15)
System.out.println("输入错误!准考证号必须15位");
else
{
if(Integer.parseInt(input.substring(14), 10) % 2 == 1)
System.out.println("考试类别A类");
else
System.out.println("考试类别B类");
StringBuffer sb = new StringBuffer(input);
//
sb.replace(5,11,"******"); //
System.out.println(sb);
}
}
}
运行测试: ideone.com/BkYtD1