자바:텍스트파일에저장된점수들을불러들여와평균구하기
-
게시물 수정 , 삭제는 로그인 필요
.자바 : 텍스트파일에 다섯학생의 성적을 저장한후 자바에 불러들여와
평균을 구하고 성적을 작으순부터 나열하는건데요ㅠ
아래는 제가 쓴건데=_ㅠ 어떤부분이 틀렷는지 봐주세요.ㅠㅠㅠㅠㅠ
고맙습니다.ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
import java.io.*;
public class J_Data
{
public static void main(String args[])
{
try
{
FileInputStream fin = new FileInputStream("data.txt");
DataInputStream dfin = new DataInputStream(fin);
int i;
int total=0;
int avg;
int[] a=new int[4];
for(i=0;i<5;i++)
total+=a[i];
avg=total/(i+1);
System.out.print(avg);
dfin.close();
}
catch(Exception e)
{
System.err.println("发生异常:"+e);
e.printStackTrace();
}
}
}
.자바 : 텍스트파일에 다섯학생의 성적을 저장한후 자바에 불러들여와
평균을 구하고 성적을 작으순부터 나열하는건데요ㅠ
아래는 제가 쓴건데=_ㅠ 어떤부분이 틀렷는지 봐주세요.ㅠㅠㅠㅠㅠ
고맙습니다.ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
import java.io.*;
public class J_Data
{
public static void main(String args[])
{
try
{
FileInputStream fin = new FileInputStream("data.txt");
DataInputStream dfin = new DataInputStream(fin);
int i;
int total=0;
int avg;
int[] a=new int[4];
for(i=0;i<5;i++)
total+=a[i];
avg=total/(i+1);
System.out.print(avg);
dfin.close();
}
catch(Exception e)
{
System.err.println("发生异常:"+e);
e.printStackTrace();
}
}
}