A school has 1800 students. The start date and leaving date for each student is stored on file. Dates are in the format YYMMDD (e.g. a student starting on 10th September 2007 and leaving on 4th August 2012 has the data 070910 and 120804 on file).
(a) Write an algorithm, using pseudocode or otherwise, which
• inputs Student ID for all 1800 students
• inputs the start date and leaving date for each student
• carries out a check to ensure the second date is later
• if error, increments error counter
• outputs the number of errors
Start
Declare variable startDate
Declare variable leavingDate
Declare variable errorCounter
Set errorCounter=0
for i =0 to 1800
Read ID from the file
Read startDate from the file
Read leavingDate from the file
if startDate> leavingDate then
errorCounter=errorCounter+1
end if
end for
Display errorCounter
Stop
Comments
Leave a comment