中文显示的问题 新手求助
本帖最后由 hunter1206 于 2013-03-10 16:12:38 编辑 import java.io.*;
public class Test50
{
String[] num=new String[5];
String[] name=new String[5];
float[][] score=new float[5][3];
float[] sum=new float[5];
public static void main(String[] args) throws IOException
{
Test50 stud=new Test50();
stud.input();
stud.output();
}
//输入学号、姓名、成绩
public void input() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
boolean flag=true; //flag为true表示已经输入
while(flag)
{
for(int i=0;i<5;i++)
{
System.out.print("请输入学号:");
num[i]=br.readLine();
System.out.print("请输入姓名:");
name[i]=br.readLine();
for(int j=0;j<3;j++)
{
System.out.print("请输入第"+(j+1)+"门课的成绩:");
score[i][j]=Integer.parseInt(br.readLine());
}
System.out.println();
sum[i]=score[i][0]+score[i][1]+score[i][2];
}
flag=false;
}
}
//输出文件
public void output() throws IOException
{
FileWriter fw=new FileWriter("d://stud.txt");
BufferedWriter bw=new BufferedWriter(fw);
bw.write("No. "+"Name"+" Score1"+" Score2"+" Score3"+" Average");
bw.newLine();
for(int i=0;i<5;i++)
{
bw.write(num[i]);
bw.write(" "+name[i]);
for(int j=0;j<3;j++)
bw.write(" "+score[i][j]);
bw.write(" "+(sum[i]/5));
bw.newLine();
}
bw.close();
}
}
No. Name Score1 Score2 Score3 Average
11 张 11.0 22.0 33.0 13.2
22 李 44.0 55.0 61.0 21.0
33 王 66.0 77.0 88.0 46.2
44 路 77.0 88.0 55.0 44.0
二 二 88.0 99.0 66.0 50.6
这是输出结果 少了一个字 这是怎么回事
还有这个问题
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入姓名:");
String name=br.readLine();
System.out.print(name);
输出的名字
--------------------Configuration: <Default>--------------------
请输入姓名:张三
张?
Process completed.
这里乱码了 如何解决 新手求助