Programming Worksheet 1
Programming Worksheet 1
Unit 6 Programming
Start
MonthlyTariff=23.00
TotalCharge =
MonthlyTariff
Input
MinutesUsed
No
MinutesUsed>600?
Yes
ExtraMinutes =
MinutesUsed - 600
ExtraCharge =
ExtraMinutes *
PerMinuteRate
TotalCharge =
TotalCharge +
ExtraCharge
Output
TotalCharge
End
1
Worksheet 1 Programming concepts
Unit 6 Programming
(b) State whether each of the following variables should be declared as a variable or a
constant, and what data type they should be given. Give reasons for your choice of
data type in each case.
(c) Assume the basic monthly tariff is £23.00 per month, and that extra minutes are
charged at 2p per minute. A customer makes calls totalling 700 minutes on their phone.
What is their total change that month?
223
2. Write pseudocode for an algorithm which calculates how much money a student will need
to buy a meal and two drinks. The user should be prompted to enter how much a meal
costs, how much a drink costs, and then calculate and display the total required.
2
Worksheet 1 Programming concepts
Unit 6 Programming
Meal_Order = int(input("How many meals do you want?"))
Task 2
3. What is output by the following algorithm if the user inputs 3, 8, 10?
Task 3
4. Write pseudocode for an algorithm which allows the user to enter their name in the format
“firstname surname”, and outputs the name in the format “initial surname”
e.g. Jim Daley will be out put as J Daley.
Assume the string in indexed from 0, so the first character in the string StrExp will be
referred to as StringExp[0].
Make use of concatenation and the following functions:
len (String Exp) finds the length of StringExp
pos (StringExp, CharExp) finds the position of a character within a string
substring(IntExp, IntExp, StringExp) e.g. substring(3, 5, “Harriet”) evaluates to “rie”)
3
Worksheet 1 Programming concepts
Unit 6 Programming
4
Worksheet 1 Programming concepts
Unit 6 Programming
5. The ASCII values for the letters ‘a’, ‘b’, ‘c’, ‘x’, ‘y’ and ‘z’ are given in the table below.
The Caesar cipher is a simple way of encrypting a message so that it cannot be read
without first decrypting it.
Each letter of the alphabet is replaced by a letter one or more places further along the
alphabet. For example, with a shift of 2, a is replaced by c, b by d,…. y by a and z by b.
Complete the pseudocode statements at (A), (B) and (C) for an algorithm which accepts a
character from the user, applies a shift of 3 characters and outputs the encrypted character.
(i) a
(ii) x