CLS
PRINT "Author: Wendy Booth"
PRINT " Welcome to my quiz!"
DIM Question AS STRING
DIM CorrectAnswer AS STRING
DIM Option1 AS STRING
DIM Option2 AS STRING
DIM Option3 AS STRING
DIM Option4 AS STRING
DIM RecordTerminator AS STRING
DIM Guess AS STRING
DIM NumCorrect AS INTEGER
DIM NumQuestions AS INTEGER
DIM PercentCorrect AS INTEGER
OPEN "quiz.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, Question
' INPUT #1, CorrectAnswer
PRINT Question;
' PRINT Option1;
PRINT Option2;
' PRINT Option3;
' PRINT Option4;
NumQuestions = NumQuestions + 1
INPUT "Answer? ", Guess
IF Guess = CorrectAnswer THEN
NumCorrect = NumCorrect + 1
PRINT "Correct!"
ELSE
PRINT "Incorrect"
END IF
LOOP
CLOSE #1
PRINT "End of quiz"
PRINT "Total number of questions"; NumQuestions
PercentCorrect = (NumCorrect / NumQuestions) * 100
PRINT "You answered"; NumCorrect; "questions correctly"
PRINT "Your percentage is"; PercentCorrect
quiz.txt is this
What color is a frog?
1
green
purple
white
blue
*
What is 2+2?
1
4
22
2
202
*
What is Jeff Hardy?
1
wrestler
dog
tree
pet
*
Where does money come from?
1
trees
flowers
parents
trash
*
Who is Jack Sparrow?
2
food
pirate
bird
chips
*
Where do pirates live?
3
house
apartment
ship
moon
*
Where does the compass point?
4
South
West
East
North
*
Where did Romeo and Juliet take place in?
3
Hawaii
Australia
Italy
Africa
*
What is Sacramento?
2
A country
A city
A food
A person
*
How long was the hundred year war?
2
100
116
1
10
*