Silverfrost Forums

Welcome to our forums

error during compilation of a program!(update)

26 Mar 2012 3:04 (Edited: 26 Mar 2012 4:27) #9903

guys, tried to compile a program to calculate student's GPA but am having this error during compilation. script of the program and error generated are here below, thanks.

! program to calculate student GPA grade implicit none integer :: no_of_courses real :: grade_point_obtain=0.0, G_P_A=0.0 real :: A=5, B=4, C=3, D=2, E=1, F=0, total=0.0 integer :: course, credit, grade real, dimension[:], allocatable :: subject real, dimension[:], allocatable :: credit real, dimension[:], allocatable :: grade print*, 'enter number of courses offered' read*, no_of_courses allocate(subject(1:no_of_courses)) do course=1,no_of_courses print*, 'type in the course code, credit_load and grade for each subject', course read*, subject(course), credit(course), grade(course) total=total+credit(course) enddo do A=70,100 print*, A enddo do B=60,69 print*, B enddo do C=50,59 print*, C enddo do D=45,49 print*, D enddo do E=40,44 print*, E enddo do F=0,39 print*, F enddo grade_point_obtain=credit(course)grade(course) G_P_A=grade_point_obtain/total print, 'the total credit_load is', total print*, 'the total grade_point_obtain is', grade_point_obtain print*, 'your GPA is', G_P_A

end

error:

C:\project7\STUDENT GPA.F95(27) : warning 1091 - Using a floating point loop variable may give unexpected results due to rounding errors C:\project7\STUDENT GPA.F95(30) : warning 1091 - Using a floating point loop variable may give unexpected results due to rounding errors C:\project7\STUDENT GPA.F95(33) : warning 1091 - Using a floating point loop variable may give unexpected results due to rounding errors Compilation failed.

having error on this now;

do A=70,100 print*, A enddo do B=60,69 print*, B enddo do C=50,59 print*, C enddo do D=45,49 print*, D enddo do E=40,44 print*, E enddo do F=0,39 print*, F enddo

26 Mar 2012 3:32 #9904

The first I see is the following: You have defined 'credit' and 'grade' as simple integer values but you want to read them as arrays. Define them as you did with 'subject', then it might run.

Regards - Wilfried

26 Mar 2012 8:28 #9906

Please try this:

program test
implicit none 
integer :: A,B,C,D,E,F, no_of_courses 
real :: grade_point_obtain=0.0, G_P_A=0.0 
real :: total=0.0 
integer :: course
real, dimension(:), allocatable :: subject 
real, dimension(:), allocatable :: credit 
real, dimension(:), allocatable :: grade 

print*, 'enter number of courses offered' 
read*, no_of_courses 
allocate(subject(1:no_of_courses))
allocate(credit(1:no_of_courses))
allocate(grade(1:no_of_courses))

do course=1,no_of_courses 
  print*, 'type in the course code, credit_load and grade for each subject', course 
  read*, subject(course), credit(course), grade(course) 
  total=total+credit(course) 
enddo 

do A=70,100 
  print*, A 
enddo 
do B=60,69 
  print*, B 
enddo 
do C=50,59 
  print*, C 
enddo 
do D=45,49 
  print*, D 
enddo 
do E=40,44 
  print*, E 
enddo 
do F=0,39 
  print*, F 
enddo 

grade_point_obtain=credit(course)*grade(course) 
G_P_A=grade_point_obtain/total 

print*, 'the total credit_load is', total 
print*, 'the total grade_point_obtain is', grade_point_obtain 
print*, 'your GPA is', G_P_A 

deallocate(subject)
deallocate(credit)
deallocate(grade)

end

Regards - Wilfried

Please login to reply.