 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
lawchellie
Joined: 22 Dec 2011 Posts: 8
|
Posted: Mon Mar 26, 2012 4:04 pm Post subject: error during compilation of a program!(update) |
|
|
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
Last edited by lawchellie on Mon Mar 26, 2012 5:27 pm; edited 1 time in total |
|
Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Mon Mar 26, 2012 4:32 pm Post subject: |
|
|
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 |
|
Back to top |
|
 |
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Mon Mar 26, 2012 9:28 pm Post subject: |
|
|
Please try this:
Code: | 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 |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|