Hi all, this question is for liberty basic (not sure if its the same or simmiler) but i am desperate for help :cry: it opens a txt file and reads the records the layout of the file is like this :

HEN01023025,Jane Henderson,10/02/1982,Maths,67
HEN01023025,Jane Henderson,10/02/1982,Science,24

i have started a program that needs to do the following "this option should print out the name of the student who has attained the highest mark in a single exam. it should show their name, the subject and the mark attained"

i have been able to get the highest gade but i need help to get the subject and grade in a print statement i.e

Print "Congratulations "; Name$; " Has attained "; Grade; " In "; Subject$
if Grade > Result$ then
   Grade = Result$
   print Grade
end if

i can do the Highest mark but i dont know how to make it so that the Name of the student and the subject that they had the mark in show up

but im stuck i have to print the information like this:

Print "Congratulations "; Name$; " Has attained "; Grade; " In "; Subject$

Thanks alot in advance :D hope you guys can help

p.s sorry that its LB not VB but i cant find a forum for it :(

Well, I just wrote this... I haven't run it and don't know if it will be compatible with Liberty Basic (this uses QBasic syntax):

The text file shouldn't need to be modified so...

HEN01023025,Jane Henderson,10/02/1982,Maths,67
HEN01023025,Jane Henderson,10/02/1982,Science,24

should do just fine. For the code of the app you should use something like...

open "data.txt" for input as 1
input #1, code$,name$,datez$,subject$,score$
close 1

print "Well done!  "+name$+" achieved grade "+score$+" in "+subject$+" on "+datez$+"."

That's only basic (ignore the pun), but if you put it inside a loop, then you should be able to get a working program.

To see who got the highest result, you could probably do an if statement inside a while loop.

Hope that helped,

thats what im kind of stuck on (to see who highest and display the subject and their mark) :) lol thanks for the code :cheesy:

Hmmm, I'lll give that a thought over the next day or so and come back to you with some c0de... perhaps.

This article has been dead for over six months. Start a new discussion instead.