Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

DCS 5038 PROGRAM DESIGN QUIZ 1 SOLUTION

QUIZ 1 SOLUTION

QUESTION (10 Marks )

Based on the following descriptions, draw the complete flowchart and write
the pseudocode.

Calculating speed based on distance and time.


 Initialize all variables.
 Get distance and time from the user.
 Calculate the speed, which is distance divided by time.
 Based on the following table, identify the status.
 Display the speed and status.

SPEED STATUS
Below 60 km/h Slow
60 - 110 Just nice
More than 110 Fast

NSH/C/UV MULTIMEDIA UNIVERSITY 1


DCS 5038 PROGRAM DESIGN QUIZ 1 SOLUTION

SOLUTION

FLOWCHART

PSEUDOCODE
BEGIN
SET speed=0, distance=0,
Time=0, status=”NONE”

PROMPT and get distance and time

speed = distance / time

IF speed < 60 THEN


status = “Slow”
ELSE
IF speed >= 60 and speed >= 110 THEN
status = “Just Nice”
ELSE
status = “Too Fast”
ENDIF
ENDIF

DISPLAY speed and status

END

NSH/C/UV MULTIMEDIA UNIVERSITY 2

You might also like