computer science -2210/22 -...
TRANSCRIPT
![Page 1: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/1.jpg)
1 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
COMPUTER SCIENCE -2210/22
Paper 2 Problem-solving and Programming October/November 2018
PRE-RELEASE MATERIAL Solution for TASK 1
(Student Version)
TASK 1 – Registering to take part.
Write a program to set up arrays to store the data for 20 children. On registration, each child must be
allocated a unique identification number of four digits; the last digit is a check digit. The unique
identification number, age in years and name for each child is recorded and stored on registration. The
PB time and the number of runs are initialized to zero and these values stored on registration. Their PB
time is stored as minutes correct to two decimal places.
#TASK1
Registration of 20 children (Iteration loop)
Input Name to an array
Input Age to an array ( validation ; 4 -14 )
Generate Registration number and store to an array ( 4 digit registration number , last digit
check digit )
Personal best set as zero
Number of runs set as zero
For Registration, have to create 5 arrays
1 2 3 .. … …. …. … 20
reg_no 1230 1241 1252
c_name nik Gan Mik
c-age 14 4 10
pb 0 0 0
n_run 0 0 0
On Registration
![Page 2: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/2.jpg)
2 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
DIM c_name(1 TO 20) AS STRING
DIM c_age(1 TO 20) AS INTEGER
DIM reg_no(1 TO 20) AS INTEGER
DIM n_run(1 TO 20) AS INTEGER
DIM pb(1 TO 20) AS REAL
reg_c = 123
FOR ct = 1 TO 20
INPUT "Enter Child Name...:"; c_name(ct)
REPEAT
INPUT "Please enter Child's Age:"; c_age(ct)
IF c_age(ct) < 4 OR c_age(ct) > 14 THEN
PRINT "Age must be 4 - 14...! Please Re-enter correct age"
END IF
UNTIL c_age(ct) >= 4 AND c_age(ct) <= 14
dig1 = INT (reg_c / 100)
temp1 = dig1 * 100
reg_temp = reg_c - temp1
dig2 = INT(reg_temp / 10)
dig3 = reg_temp MOD 10
ch_dig = ((dig1 * 3) + (dig2 * 2) + (dig3 * 1)) MOD 10
reg_no(ct) = reg_c * 10 + ch_dig
reg_c = reg_c + 1
n_run(ct) = 0
pb(ct) = 0
PRINT c_name(ct); " Registered Successfully...!!Please note the
Registration number!!"
PRINT reg_no(ct); ":"; c_name(ct);
NEXT ct
Practice Questions
1. Declare arrays you used for Task 1 and state the purpose of each one. 2. Write an algorithm to complete Task1 ( with validation and without validation ) 3. Explain how your program allocates unique registration number ( Task1) 4. Extend Task 1 for 50 children. (redo question 1 to 3 ) 5. Give 3 different ages that you could use to check the validation used in Task1. Explain why you
use each one. 6. Comment on the efficiency of your design for Task 1. 7. Comment any weakness/ limitation of your design for Task1
Commented [NIK1]: Array Declarations c_name to Store Children’s Name c_age to store Age of the children reg_no to store the register number of each child n_run to store number of events attended by each child pb to store personal best of each child
Commented [NIK2]: Initialize 3-digit number for Register number generation
Commented [NIK3]: Loop for input and store 20 children details
Commented [NIK4]: Input Child Age with validation
Commented [NIK5]: Extracting 3 digits separately from the initialized three-digit registration constant, reg_c
Commented [NIK6]: Creating the Register Number (4 digit)
Commented [NIK7]: Registration constant value increment by 1 for next student input
Commented [NIK8]: The PB time and the number of runs are initializing to zero
Commented [NIK9]: Output Child’s Registration number with Name
![Page 3: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/3.jpg)
3 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
COMPUTER SCIENCE -2210/22
Paper 2 Problem-solving and Programming October/November 2018
PRE-RELEASE MATERIAL Solution for TASK 2
(Student Version)
TASK 2 – Recording the times.
Extend your program to record the unique identification number and to input the start time and finish
time for every child completing the junior park run event. Calculate and store the time each child took
to complete the run. A registered child does not have to compete in each event. Only one time per child
is recorded during an event.
#TASK2
Input Register Number and Search in the array , reg_no[20]
If Register Number found,
Input Start Time ( HH, MM,SS format )
Input Finish Time ( HH, MM, SS format)
Calculate the time difference in second , adjust to 2dp and store to a new array (event record)
Update Personal best (under conditions)
Update Number of Runs
1 2 3 .. … …. …. … 20
reg_no 1230 1241 1252 ...... 1434
c_name nik Gan Mik ..... Ami
c-age 14 4 10 ..... 7
pb 0 0 0 ..... 0
n_run 0 0 0 ..... 0
ev_record .....
At
the
end
of
Task
1, a
ll th
ese
5 a
rray
s w
ill
con
tain
20
ch
ildre
n’s
reg
istr
atio
n d
etai
ls
New array created to store each child’s current event (run) duration in minutes [2dp]
Optional for Task 2
![Page 4: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/4.jpg)
4 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
DIM ev_record(1 TO 20) AS REAL
DIM ch AS STRING
DIM rpos AS INTEGER
REPEAT
rpos = 0
INPUT "Please Enter Child Register Number"; reg
FOR ctr = 1 TO 20
IF reg_no(ctr) = reg THEN rpos = ctr
NEXT
IF rpos <> 0 THEN
PRINT "Enter Event details of "; reg_no(rpos); ":"; c_name(rpos)
INPUT "Enter Start time (HH, MM, SS)"; sh, sm, ss
st_min = (sh * 60) + sm + (ss / 60)
INPUT "Enter Finish time (HH, MM, SS)"; fh, fm, fs
ft_min = (fh * 60) + fm + (fs / 60)
dur_min = ft_min - st_min
dur_min = INT(dur_min * 100)
dur_tdp = dur_min / 100
ev_record(rpos) = dur_tdp
n_run(rpos) = n_run(rpos) + 1
IF pb(rpos) = 0 OR dur_tdp < pb(rpos) THEN
pb(rpos) = dur_tdp
PRINT "Personal Best updated!!"
END IF
ELSE
PRINT “Entered Register Number Not found!!!”
END IF
INPUT "Do you need to record more children's event details...? (Y/N)"; ch
UNTIL (ch = "N" OR ch = "n")
Optional for Task2.
Task 3 extending
from here
Commented [NIK10]: Array Declaration for storing each student’s event duration time in minutes
Commented [NIK11]: Variable for control/continue / terminate the input
Commented [NIK12]: Loop for input the details of Participant’s details.
Commented [NIK13]: Once the input Register number found, that array position will store to this variable,
Commented [NIK14]: Searching for the details of entered register number. Once it found, array position of the register number will store to ‘rpos’ variable. eg:- if 1252 is the input register Number , rpos will be 3.
Commented [NIK15]: Entered Register Number found ( rpos will be non zero integer between 1 and 20)
Commented [NIK16]: Displays the child Name and register number (optional Step)
Commented [NIK17]: Input the Start time of the child and changing the time to minutes
Commented [NIK18]: Input the Finish time of the child and changing the time to minutes
Commented [NIK19]: Time taken for the run (in minutes)
Commented [NIK20]: Adjusting the calculated Duration time for 2dp
Commented [NIK21]: Record the Child’s event duration into array. Adding 1 to the child’s number of events participated
Commented [NIK22]: Updating the Personal Best. Considering two conditions here-
1.Child’s First event ( pb =0)
2. Update the Personal best only if new duration is less than existing one.
Commented [NIK23]: Error message for Invalid Register number
Commented [NIK24]: For recording next child event details / stop the inputs
![Page 5: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/5.jpg)
5 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
Practice Questions
8. State name , data type and use of arrays used in Task2 9. State name , data type and use of variables used in Task2 10. Write an algorithm to complete Task2 ( Assume that Task 1 completed ) 11. Explain how your program for Task 2 calculating the duration in minutes and rounding to two
decimal place. 12. Comment on the efficiency of your design for Task 2. 13. Comment any weakness/ limitation of your design for Task2
![Page 6: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/6.jpg)
6 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
COMPUTER SCIENCE -2210/22
Paper 2 Problem-solving and Programming October/November 2018
PRE-RELEASE MATERIAL Solution for TASK 3
(Student Version)
TASK 3 – Updating the children’s data and identifying the fastest child for each age range.
Extend your program to update the number of runs and the PB time if necessary for every child
completing the junior park run event. Check if any half- or full-marathon wristbands need to be
awarded. Output the names and the type of wristbands. Output the names and the times of the fastest
child at this event for each of the age ranges 4 to 6, 7 to 10 and 11 to 14.
#TASK3 Extend Task 2 …. Update personal Best (pb) Update number of runs Check for Half Marathon wristband ( number of run =11) Check for Full Marathon Wristband ( number of run =22) Fastest child , age group 4-6 Fastest child , age group 7-10 Fastest child , age group 11-14
Ch As String
fmar = 22
hmar = 11
Repeat
ev_record(rpos)= dur
IF pb(rpos) = 0 OR dur_tdp < pb(rpos) THEN
pb(rpos) = dur_tdp
PRINT "Personal Best updated!!"
END IF
n_run(rpos) = n_run(rpos)+1
IF n_run(rpos)= hmar THEN PRINT “ HALF MARATHONE WRISTBAND for” c_name(rpos)
IF n_run(rpos)= fmar THEN PRINT “ FULL MARATHONE WRISTBAND for” c_name(rpos)
INPUT "Do you need to record more children's event details...? (Y/N)"; ch
UNTIL (ch = "N" OR ch = "n")
// Array position (rpos) of the input
register number identified and the duration
of the child (dur) calculated in Task 2
Commented [NIK25]: Number of runs for Full marathon and half marathon
Commented [NIK26]: Updating the Personal Best. Considering two conditions here-
3.Child’s First event ( pb =0)
4. Update the Personal best only if new duration is less than existing one.
Commented [NIK27]: Checking for Half / Full marathon wristband award
![Page 7: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/7.jpg)
7 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
best_fg = 1440
best_sg = 1440
best_tg = 1440
pos_fg = 0
pos_sg = 0
pos_tg = 0
FOR ctl = 1 TO 20
IF pb(ctl) > 0 THEN
IF c_age(ctl) >= 4 AND c_age(ctl) <= 6 THEN
IF pb(ctl) < best_fg THEN
best_fg = pb(ctl)
pos_fg = ctl
END IF
END IF
IF c_age(ctl) >= 7 AND c_age(ctl) <= 10 THEN
IF pb(ctl) < best_sg THEN
best_sg = pb(ctl)
pos_sg = ctl
END IF
END IF
IF c_age(ctl) >= 11 AND c_age(ctl) <= 14 THEN
IF pb(ctl) < best_tg THEN
best_tg = pb(ctl)
pos_tg = ctl
END IF
END IF
END IF
NEXT ctl
PRINT "Fastest Child in the age group 4-6"; pb(pos_fg); ":"; c_name(pos_fg)
PRINT "Fastest Child in the age group 7-10"; pb(pos_sg); ":"; c_name(pos_sg)
PRINT "Fastest Child in the age group 11-14"; pb(pos_tg); ":"; c_name(pos_tg)
Commented [NIK28]: Initial value for finding Best/Lowest PB value from three age groups. Fist Group (4-6), Second Group(7-10), Third Group(11-14)
Commented [NIK29]: Position value for three age groups.
Commented [NIK30]: Loop for searching the arrays
Commented [NIK31]: The children those not attended any event, PB value will be Zero. No need to consider those values for checking fastest.
Commented [NIK32]: To find the Fastest child in the age group 4-6
Commented [NIK33]: To find the Fastest child in the age group 7-10
Commented [NIK34]: To find the Fastest child in the age group 11-14
Commented [NIK35]: Print all the three age Group’s fastest child details (Register number & name)
![Page 8: COMPUTER SCIENCE -2210/22 - maxpapers.commaxpapers.com/wp-content/uploads/2018/10/PRE_2018_igcse_gce-o-level.pdf · 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’–Mob:](https://reader030.vdocuments.us/reader030/viewer/2022041301/5e1129f31af5980d913148a3/html5/thumbnails/8.jpg)
8 2210/22/PRE/O/N/18 ©NIKHIL VM , ISKANDHAR School, Male’– Mob: +960 9110191 Date: 01st Sept 2018
Practice Questions
1. State name , data type and use of variables used in Task3. 2. State the name of constant variables and its value that used in Task3. 3. Write an algorithm to complete Task3 ( Assume that Task 1 & Task2 completed ) 4. Write an algorithm to update personal Best and number of run in Task 3. 5. Explain how your program for Task 3 updating the personal best and number of runs. 6. Explain how your program for Task 3 checking half or full marathon wristband needs to be
award. 7. Explain how your program for Task 3 calculating the fastest child at this event for each of the
age ranges 4 to 6, 7 to 10 and 11 to 14. 8. Comment on the efficiency of your design for Task 2. 9. Comment any weakness/ limitation of your design for Task2