中文显示的问题 新手求助
本帖最后由 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]);