Question 5-Compulsory
5. Consider the following pseudocode design for determining the speed
of a person traveling in a residential area. The more the speed limit is
exceeded, the greater the fine applicable. Answer the questions that
follow:
LINE 1 START
LINE 2
LINE 3
LINE 4
LINE 5
LINE 6
LINE 7
LINE 8
LINE 9
LINE 10
LINE 11
LINE 12
LINE 13
LINE 14
LINE 15
LINE 16
LINE 17
LINE 18
END IF
LINE 19 PRINT "Your fine is: ", fine
LINE 20 PRINT "Have a nice day!"
LINE 21 STOP
DECLARE speed AS INTEGER
PRINT "Enter traveling speed:
READ speed
IF speed 50 then
fine = 2000
ELSE
IF speed 80 then
fine = 4000
ELSE
IF speed 120 then
fine = 7000
ELSE
fine = 0
PRINT "No fine."
END IF
END IF
(a) With the aid of a trace table, write the output that would be displayed
for the variable fine after tracing through the above pseudocode (the
NESTED-IF design) if the user entered the following data for
speed?
Speed
50
90
140
35
(b) Based on your evaluation, is the pseudocode above correct or incorrect?
Justify your answer, and state how, if at all, the pseudocode should be
corrected.



Answer :

Other Questions