program calculation_of_grade
use ord
integer, dimension (100)::id
character(len=25), dimension (100)::name
real,dimension(100,8)::note,temp
character(len=75)::firstrow,temp_2
real::average,temp_1
integer::i,j,ios,a
i=0
open(unit=1,file="C:\Documents and Settings\Administrator\Desktop\proje\notoku\veri.dat",status="old",action="read")
open(unit=2,file="veri.out",status="unknown",action="write")
read(unit=1,fmt="(a75)")firstrow
print*,firstrow
read(unit=1,fmt="(a75)")firstrow
write(unit=2,fmt=*)firstrow
print*,firstrow
do
  i=i+1
   read(unit=1,fmt="(i10,a25,7f5.1)",iostat=ios)id(i),name(i),note(i,1:7)
   print*,"i=",i," ios=",ios

   if(ios<0)then
    exit
   end if
!  write(unit=2,fmt="(i10,a25,7f5.1)")id(i),name(i),note(i,1:7)
 !  write(unit=*,fmt="(i10,a25,7f5.1)")id(i),name(i),note(i,1:7)
enddo
i=i-1
print*,"Number of students: ",i

do j=1,i
 note(j,8)=sum(note(j,1:4))*0.05+sum(note(j,5:6))*0.20+note(j,7)*0.40
!write(unit=2,fmt="(i10,a25,8f5.1)")id(j),name(j),note(j,1:8)

!write(unit=*,fmt="(i10,a25,8f5.1)")id(j),name(j),note(j,1:8)
enddo
average=sum(note(1:i,8))/i
print*,"Average of Class: ",average
call ord1(id,name,note)
do a=1,i
write(unit=*,fmt="(i10,a25,8f5.1)")id(a),name(a),note(a,1:8)
enddo

end program calculation_of_grade

