Professional Documents
Culture Documents
Exercises Page 14
1. X = A * B + C ^ 4
2. X = (C – D) / E + 5) – 5 * D
3. X = 17 * B * C – B ^ (E – A)
Exercises Page 30
Question 1
The following answers are merely suggestions. Any valid answer will be correct.
Question 2
2.1 noMarbles
2.2 amtDue
2.3 registered
2.4 height = 1.75
2.5 personName
2.6 code = “K”
2.7 dogDescr = “Dachshund”
2.8 noSmarties
2.9 weekDays = 7
2.10 notice = “No Entry”
2.11 vat = 0.14
3.1 x = a - bc2
x =a–b*c^2
Substitute values:
x = 84 – 3 * 4 ^ 2
= 84 – 3 * 16
= 84 – 48
= 36
3.2 x = k mod 5 + m \ n – 3n
= k mod 5 + m \ n – 3 * n
Substitute values:
x = 34 mod 5 + 33 \ 7 – 3 * 7
= 34 mod 5 + 33 \ 7 – 21
= 34 mod 5 + 4 – 21
= 4 + 4 – 21
= 8 – 21
= -13
Question 4
Question 5
5.1
Variables (Integer) noPairsSocks
(Real) amountDue
Constant (Real) price = 3.5
Equation amountDue = noPairsSocks * price
5.2
Variables (Integer) test1, test2
(Real) aveMark
Constant (Real) noTests = 2
Equation aveMark = (test1 + test2) / noTests
5.3
Variables (Integer) numMarbles, numPerChild
Equation numPerChild = numMarbles \ 4
The number 4 could have been declared as a constant in this exercise.
5.5
Variables (Integer) noPages
(Real) copyPrice
Constant (Real) coverPrice = 1.5
doublePagePrice = 0.45
Equation copyPrice = coverprice + noPages / 2 * doublePagePrice
5.6
Variables (Integer) noItems
(Real) amtDue
Constant (Real) price = 5.6
discount = 0.05
vat = 0.14
Equation amtDue = noItems * price * (1 – discount) * (1 + vat)
This is only one way of writing the equation.
5.7
Variables (Integer) points1, points2
(Real) avePerc
Constant (Integer) total1 = 34
total2 = 125
Equation avePerc = (points1 / total1 * 100 + points2 / total2 * 100) / 2
5.8
Variables (Integer) length1, length2, length3
(Real) totalLength
Constant (Integer) numLines = 3
cmInM = 100
Equation totalLength = (length1 + length2 + length3) / numLines / cmInM
5.9
Variables (Integer) totalBiscuits, packetsBiscuits, remBiscuits
Constant (Integer) numInPacket = 15
Equation packetsBiscuits = totalBiscuits \ numInPacket
remBiscuits = totalBiscouts mod numInPacket