04-07-2005, 06:48 PM
Trying for last few weeks to find out how to get ma program i designed for College to read specific data from ma database.
when program finished should show Pass Mark of 40% should output the following:-
· The number of students taking the exam.
· The number of students passing the exam.
· The number of students failing the exam.
· The average mean examination mark.
· The average examination pass mark.
TEST DATA Smith=70 , Peters=35, Osborne=45, Jenkins=53, Evans=40, Davies=51, Adams=75
included to code below.
REM STUDENT SCORES
SCREEN 13
FOR t = 1 to 255
COLOR t
PRINT "o"
NEXT t
[b][b]CLS
TYPE studentType
Lastname AS STRING * 30
Mark AS INTEGER
END TYPE
DIM student AS studentType
PRINT "1.) Create new recordset"
PRINT "2.) View existing recordset"
PRINT "3.) Students that passed"
INPUT "Which option? ", selection%
IF selection% = 1 THEN
INPUT "How many students are there? ", numRecords%
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
FOR i% = 1 TO numRecords%
CLS
INPUT "Last name: ", student.Lastname
INPUT "Mark: ", student.Mark
PUT #1, , student
NEXT i%
CLS
CLOSE #1
PRINT "Recordset creation complete"
END
END IF
IF selection% = 2 THEN
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
format$ = "\ \ ### "
PRINT "Last name Mark "
PRINT "------------------ -----"
DO WHILE NOT EOF(1)
GET #1, , student
PRINT USING format$; student.Lastname; student.Mark
LOOP
CLOSE #1
END
END IF
IF selection% = 3 THEN
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
ELSEIF Mark >= 40 THEN
format$ = "\ \ ### "
PRINT "Last name Mark "
PRINT "------------------ -----"
DO WHILE NOT EOF(1)
GET #1
PRINT USING format$; student.Lastname; student.Mark
LOOP
CLOSE #1
END
END IF
when program finished should show Pass Mark of 40% should output the following:-
· The number of students taking the exam.
· The number of students passing the exam.
· The number of students failing the exam.
· The average mean examination mark.
· The average examination pass mark.
TEST DATA Smith=70 , Peters=35, Osborne=45, Jenkins=53, Evans=40, Davies=51, Adams=75
included to code below.
REM STUDENT SCORES
SCREEN 13
FOR t = 1 to 255
COLOR t
PRINT "o"
NEXT t
[b][b]CLS
TYPE studentType
Lastname AS STRING * 30
Mark AS INTEGER
END TYPE
DIM student AS studentType
PRINT "1.) Create new recordset"
PRINT "2.) View existing recordset"
PRINT "3.) Students that passed"
INPUT "Which option? ", selection%
IF selection% = 1 THEN
INPUT "How many students are there? ", numRecords%
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
FOR i% = 1 TO numRecords%
CLS
INPUT "Last name: ", student.Lastname
INPUT "Mark: ", student.Mark
PUT #1, , student
NEXT i%
CLS
CLOSE #1
PRINT "Recordset creation complete"
END
END IF
IF selection% = 2 THEN
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
format$ = "\ \ ### "
PRINT "Last name Mark "
PRINT "------------------ -----"
DO WHILE NOT EOF(1)
GET #1, , student
PRINT USING format$; student.Lastname; student.Mark
LOOP
CLOSE #1
END
END IF
IF selection% = 3 THEN
recordLen# = LEN(student)
OPEN "e:\database.dat" FOR RANDOM AS #1 LEN = recordLen#
ELSEIF Mark >= 40 THEN
format$ = "\ \ ### "
PRINT "Last name Mark "
PRINT "------------------ -----"
DO WHILE NOT EOF(1)
GET #1
PRINT USING format$; student.Lastname; student.Mark
LOOP
CLOSE #1
END
END IF