A FlashCard Program:

! Flashcard program for self-test questions of Chapter 7 in Catlin text

! This program requires lots of error traps that were not included.

 

PRINT "ST7.1 What is an advantage of ";

PRINT "writing a program as a ";

PRINT "collection of small program units?"

PRINT

PRINT "a. It shortens the program"

PRINT "b. It makes the program easier to understand"

PRINT "c. Such programs are easier to write and debug"

PRINT "d. The progam is easier to maintain and modify"

PRINT "e. Because it is modular, it is a True Basic module"

PRINT

PRINT "Enter each correct answer (a,b,c,d,e) or q"

 

!Pseudocode:

!1. accumulate points up to 10

!2. set points = 0

!3. if answer is a,e then print incorrect and deduct 2 points

!4. if answer is b,c,d then add 2 to points print correct

!5. if answer is q then quit and print total points out of 10

!6. do not permit use of duplicate answers (not yet included...your exercise)

 

LET points = 0

DO until answer$ = "q"

INPUT prompt "Your answer ": answer$

IF answer$ = "a" then

PRINT "Sorry, incorrect "

LET points = points - 2

END IF

IF answer$ = "b" then

PRINT "Correct!"

LET points = points + 2

END IF

IF answer$ = "c" then

PRINT "Correct!"

LET points = points + 2

END IF

IF answer$ = "d" then

PRINT "Correct!"

LET points = points + 2

END IF

IF answer$ = "e" then

PRINT "Sorry, incorrect "

LET points = points - 2

END IF

 

PRINT "Points so far ... ";points

LOOP

PRINT "Your score on this question was ...";points; " out of 10"

END

 

 


One possible output for this program (with no cheating):

 

ST7.1 What is an advantage of writing a program as a

collection of small program units?

 

a. It shortens the program

b. It makes the program easier to understand

c. Such programs are easier to write and debug

d. The progam is easier to maintain and modify

e. Because it is modular, it is a True Basic module

 

Enter each correct answer (a,b,c,d,e) or q

Your answer a

Sorry, incorrect

Points so far ... -2

Your answer b

Correct!

Points so far ... 0

Your answer c

Correct!

Points so far ... 2

Your answer d

Correct!

Points so far ... 4

Your answer e

Sorry, incorrect

Points so far ... 2

Your answer q

Points so far ... 2

Your score on this question was ... 2 out of 10