Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
28 views14 pages

Nesrine Programming MS

The document covers programming concepts including pseudocode structures such as loops and conditional statements, as well as algorithms for calculating scores and handling arrays. It includes examples of pseudocode for various tasks, marking points for correct implementations, and explanations of how to manage data in programming. Additionally, it discusses file handling benefits, emphasizing data permanence and reusability.

Uploaded by

wuw6904
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views14 pages

Nesrine Programming MS

The document covers programming concepts including pseudocode structures such as loops and conditional statements, as well as algorithms for calculating scores and handling arrays. It includes examples of pseudocode for various tasks, marking points for correct implementations, and explanations of how to manage data in programming. Additionally, it discusses file handling benefits, emphasizing data permanence and reusability.

Uploaded by

wuw6904
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Quick Answers X

8.1 Programming Concepts MS Combined By NESRINE

Questionl

a)

Pseudocode description Pseudocode statement

FOR..TO ...NEXT
a loop that will always iterate at
least once

I F ...THEN ...ELSE...ENDI F
a conditional statement to deal
with many possible outcomes

WHILE...DO...ENDWHILE
a loop that will always iterate a set
number of times

CASE ...OF...OTHERWISE...ENDCASE

a conditional statement with


different outcomes for true and false

REPEAT...UNTIL

[Total: 4 mar1<s]

Question2

B: [l mark)

[Total: 1 mark]

Question3

C; [l mark]

[Total: 1 mark] 1/8


Question4a
8.1 Programming Concepts MS Combined By NESRINE

a) One mark for each correct line.

DECLARE X STRING
DECLARE Y INTEGER
DECLARE Z INTEGER

[Total: 3 marks]

Question4b

b) One mark for storing string in x.

One mark for calling the function length.

One mark for using the correct parameter x.

One mark for using the substring function.

One mark for correct parameters.

One mark for outputting length and substring return values.

For example:
X � "Programming is fun 11
OUTPUT Length(X)
Y +- 16
Z +- 3
OUTPUT SubString(X,Y,Z)

[Total: 6 marks] 2/8


Questions
8.1 Programming Concepts MS Combined By NESRINE

i) Maximum 5 marks in total for question part


Maximum 3 marks for algorithm

Description (max 3)
- set variable called HighestScore to zero and variable called BestName to dummy value
- loop 30 times to check each student's total score in turn
- check student's score against HighestScore
- if student's score> HighestScore then
- ,,,,, replace value in HighestScore by student's score and store student's name in BestName
- output BestName and HighestScore outside the loop

Sample algorithm (max 3):

HighestScore +- 0
BestNai-.'"'lle � \'xxxx" (l mark)
FOR Count +- 1 TO 30
IF StudentTotalScore[Count] > HighestScore (1 mark)
THEN
H�ghestScore +- StudentTotalScore[Count]
BestName +- StudentName[Count] (1 mark)
ENDIF
NEXT Count (1 mark)
PRINT BestName, HighestScore (l mark)

If algorithm or program code only, then maximum 3 marks

ii) comment on which student(s)' name will be output: [l mark]

e.g. The first student with the highest score will be output

[Total: 6 marks] 3/8


Question6a
8.1 Programming Concepts MS Combined By NESRINE

a) marking_Qoints:

the way to find and print the largest value a lmark


the way to find and print the largest value b lmark
the way to find and print the largest value c l mark

samQle algorithm:

INPUT a, b, c
IF a > b AND a > C THEN PRINT a (l mark)
ELSE IF b > c THEN PRINT b (l mark)
ELSE PRINT c (l mark)

[Total: 3 marks]

Question6b

b) marking points:

loop construct l mark


check if number is an integer l mark
counting the number of integers input l mark
output count value (outside the loop) l mark

samQle algorithm:

FOR x � 1 TO 1000 (l mark)


INPUT Nu.rnber
Difference � INT(number) - Number (l mark)
IF Difference = 0 THEN Total� Total + 1 (l mark)
NEXT x
PRINT total (l mark)
(NOTE: alternative to lines 3 and 4:
IF INT(Number) = Number THEN Total� Total + 1 (2 marks))

[Total: 4 marks]
4/8
Question7a
8.1 Programming Concepts MS Combined By NESRINE

i) Many correct answers. They must be meaningful and related to Task 1. The names are examples only.

One mark per mark point

• Constant MaxCandidates
• Value 4
• Use The value of the maximum number of candidates for the election

ii) Many correct answers. They must be meaningful and related to Task 1. The names are examples only.

One mark per mark point

• Variable Ntunbercandidates
• Use Storing the number of candidates in the election (for a tutor group)

• ArraycandidateNames
• Use Storing the names of the candidates for the election

[Total: 7 marks]

Question7b

b) One mark per mark point (Max 4)

MPl Change the value of the MaxCandidates constant/variable to 8


MP2 Change the input message to state the maximum number of candidates is 8 ...
MP3 ...how your program changed the input message
MP4 Change the loop limit to up to 8 ...
MPS ...how your program changed the loop limit
MP6 Change the validation to allow input up to 8 ...
MP? ...how your program changed its validation check
MP8 Change the array size(s) to ensure sufficient capacity to store up to 8 names ...
MP9 ...how your program changed the array sizes
MPl0 Change the counters to ensure votes can be counted for up to 8 candidates ...
MPll ...how your program changed its counters

[Total: 4marks] 5/8


Question7c
8.1 Programming Concepts MS Combined By NESRINE

c) Any five from:

MPl Input with message to enter unique voter number


MP2 Validation of (unique) voter number entered e.g. length check/type check/range check
MP3 Attempt to check if voter number input is in list of possible voters
MP4 Attempt to check if they have already voted
MPS If voter has already voted, message to warn them they can't vote
MP6 Attempt at preventing them from voting
MP? Store voter number in a suitable data structure

[Total: 5 marks]

Example answer
OUTPUT "Please enter your unique voter number"
INPUT UniqueVoterNumber
FoundFlag � False
AllNumbersChecked � False
Counter � 0
WHILE FoundFlag = False AND AllNumbersChecked = False
IF StudentNumbers[Counter] = ""
THEN
AllNu.�bersChecked = True
StudentNumbers[Counter] � UniqueVoterNumber
ELSE
IF UniqueVoterNumber = StudentNumbers[Counter]
THEN
FoundFlag = True
PRINT "Sorry, you have already voted"
ELSE
Counter = Counter + 1
ENDIF
ENDIF
ENDWHILE
IF FoundFlag = False
THEN
OUTPUT "Please enter the code of your chosen candidate"
INPUT Vote
ENDIF 6/8
Question7d 8.1 Programming Concepts MS Combined By NESRINE

d) Explanation of how the program does the following:

Any four from:

MPl Find out how many votes in total (for all candidates) were cast in the election.
MP2 For each candidate
MP3 ... calculate the percentage of votes
MP4 ... excluding abstentions.
MPS Display the name of each candidate, the number of votes and the percentage of votes they
received with appropriate messages.
MP6 Display the number of votes cast and the number of abstentions with appropriate message.

[Total: 4 marks]

Questions

One mark per bullet point

37

• Data type name Integer


• Data type description (Any) whole number

Cambridge2021

• Data type name String


• Data type description A group of characters/text

47.86

• Data type name Real


• Data type description (Any real) number that could be a whole number or a fraction

[Total: 6 marks]
7/8
Question9 8.1 Programming Concepts MS Combined By NESRINE

Any three correct statements (Max 3) e.g.

MPl Add an input facility to allow teachers to enter the class size
MP2 Add a variable to store the input class size
MP3 Use the class size variable as the terminating condition for the loop
MP4 Make sure the arrays are sufficiently large to accommodate the largest possible class size

[Total: 3 marks]
8/8
Quick Answers 8.2 Arrays MS Combined By NESRINE
Questionl
i) Many correct answers, they must be meaningful. This is an example only; [l mark]

StudentNa�es[l:30!

ii) Many correct answers, they must be meaningful. This is an example only.
StudentMarksTestl[l:301
StudentMarksTest2[1:30)
StudentMarksTest3 [1: 30 J (1 mark)
StudentTotalScore[1: 30) (1 mark)

[Total: 3 marks]

Question 2

One mark per mark point (Max 3)

MPl Correct loop, including counter if not a FOR loop


MP2 Correct output of score [ J
MP3 Correct output of Grade [ J
MP4 Suitable messages/text in output for both arrays

[Total: 3 marks]

Example answers
Count ,-. 0
REPEAT
PRINT "Student: ", Count, " Mark: ", Score[Countl, " Grade: ",Grade[Count)
Count ,-. Count + 1
UNTIL Count = 30

Count ,-. 0
WHILE Count < 30 DO
PRINT "Student: ", Count, " Mark: ", Score[Count], 11 Grade: 11 ,Grade[Count]
Count ,-. Count + 1
ENDWHILE

FOR Count,-. 0 TO 29
PRINT "Student: " Count, " Mark: ", Score[Count], " Grade: ", Grade[Count]
NEXT 1/5
Question3 8.2 Arrays MS Combined By NESRINE

• appropriate loop controls


• read from array
• output from array (the last two points can be in one statement, see example)

Note: reading and the output MUST be within the same loop.

For example:

Count .... 0
WHILE Count < 50 DO
OUTPUT Name[Count]
Count .... Count + 1
2NDWHILE

[Total: 3marks] 2/5


Question4 8.2 Arrays MS Combined By NESRINE

Read the whole answer, award a mark from both of the following tables and add up the total.

Marks are available for:

• A02 (maximum 9 marks)


• A03 (maximum 6 marks).

The techniques and the data structures required are listed below. The requirements may be met using a suitable built-in
function from the programming language used (e.g. Python, VB.NET or Java).

Techniques required:

Rl Calculate total mark for each student (iteration and totalling).


R2 Calculate average mark for each student rounded to the nearest whole number.
R3 Selection of grade for each student (selection).
R4 Output for each student name, total mark, average mark, grade awarded (output with appropriate messages).
RS Calculate, store and output the number of distinctions, merits, passes and fails for the whole class (iteration,
counting and output with appropriate messages).

Data structures required:

The names underlined must be used as provided in the scenario.

Arrays or lists StudentName, StudentMark,_


(TotalMark and AverageMark may be seen but no requirement to store)

Variables Ci asssi ze, SubjectNo,_ SubjectCounter, StudentCounter


DistinctionNo, MeritNo, PassNo, FailNo couldbean array or list

Constants Distinction, Merit, Pass could be variables 3/5


Example 15 mark answer in pseudocode.
8.2 Arrays MS Combined By NESRINE

// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLF��E TotalMark : ARRAY[l:50] OF INTEGER
DECLF-�E AverageMark : ARRAY[l:50] OF INTEGER
DECLF-�E SubjectCounter INTEGER
DECLARE StudentCounter INTEGER
DECLF��E DistinctionNo : INTEGER
DECLF-�E MeritNo : INTEGER
DECLF-�E PassNo INTEGER
DECLARE FailNo INTEGER

CONSTANT Distinction = 70
CONSTANT Merit = 55
CONSTANT Pass = 40

// initialisation processes for this scenario, initialising the running totals used for
// grades and combined totals
DistinctionNo ... 0
MeritNo � 0
PassNo ... 0
FailNo +- 0

FOR StudentCounter ... 1 to Classsize


TotalMark[StudentCounter] ... 0
NEXT StudentCounter

// programming techni ques of iteration, selection, totalling, counting and output are used 4/5
// programming techniques of iteration, selection, totalling, counting and output are used
8.2 Arrays MS Combined By NESRINE

FOR StudentCounter � 1 to ClassSize


FOR SubjectCounter � 1 to SubjectNo
TotalMark[StudentCounter] � TotalMark[StudentCounter] + StudentMark[StudentCounter,
SubjectCounter]
NEXT SubjectCounter
AverageMark[StudentCounter] � INT((TotalMark[StudentCounter] / SubjectNo) + 0.5)
OUTPUT "Name ", StudentName[StudentCounter]
OUTPUT "Combined total mark ", TotalMark[StudentCounter]
OUTPUT "Average mark ", AverageMark[StudentCounter]
IF AverageMark[StudentCounter] >= Distinction
THEN
DistinctionNo � DistinctionNo + 1
OUTPUT "Grade Distinction"
ELSE
IF AverageMark[StudentCounterj >= Merit
THEN
MeritNo � MeritNo + 1
OUTPUT "Grade Merit"
ELSE
IF AverageMark[StudentCounter] >= Pass
THEN
PassNo � PassNo + 1
OUTPUT "Grade Pass"
ELSE
FailNo � FailNo + 1
OUTPUT "Grade Fail"
ENDIF
ENDIF
ENDIF
NEXT StudentCounter

OUTPUT "Number of Distinctions " I DistinctionNo


OUTPUT "Number of Merits " MeritNo
OUTPUT ''Nu.rn.ber of Passes " , PassNo
OUTPUT ''Nu..rn.ber of Fails " , FailNo

[Total: 15 marks]
5/5
Quick Answers 8.3 File Handling MS Combined By NESRINE
X

Questionl

Any three from:

• data is not lost when the computer is switched off// data is stored permanently
• data can be used by more than one program or reused when a program is run again
• data can be backed up or archived
• data can be transported from one place/ system to another.

[Total: 3 marks]

1/1

You might also like