replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - logical error (pls help!)
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

logical error (pls help!)

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
lawchellie



Joined: 22 Dec 2011
Posts: 8

PostPosted: Mon Apr 02, 2012 5:13 pm    Post subject: logical error (pls help!) Reply with quote

! program to calculate student GPA grade
implicit none
integer :: no_of_courses
real :: grade_point_obtain=0.0, total=0.0, G_P_A=0.0
integer :: course
real, dimension[:], allocatable :: credit
real, dimension[:], allocatable :: grade
print*, 'enter number of courses offered'
read*, 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 credit_load and grade for each subject', course
read*, credit(course), grade(course)
total=total+credit(course)
grade_point_obtain=total+(grade(course)*credit(course))
enddo

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(credit)
deallocate(grade)

end

the program code above to calculate a student's GPA is running but i am having a logical error,what i mean is that when i run it the total credit load is correct but the grade _point_obtain happened not to be correct, i have tried to correct this but to no avail. pls help, if possible run and confirm. thanks

below is a piece of the program when run:

enter number of courses offered
3
type in the credit_load and grade for each subject 1
3,4
type in the credit_load and grade for each subject 2
3,2
type in the credit_load and grade for each subject 3
3,5
the total credit_load is 9.00000
the total grade_point_obtain is 24.0000
your GPA is 2.66667

Press RETURN to close window . . .
Back to top
View user's profile Send private message
brucebowler
Guest





PostPosted: Mon Apr 02, 2012 6:23 pm    Post subject: Re: logical error (pls help!) Reply with quote

lawchellie wrote:
grade_point_obtain=total+(grade(course)*credit(course))


I'd guess that the "total" in the above line should really be "grade_point_obtain"

Bruce

PS - you should point out to your professor that you got help on this...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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