0% found this document useful (0 votes)
17 views

Intro to programming assignment 3

Introduction to programming assignemtn 3 2024

Uploaded by

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

Intro to programming assignment 3

Introduction to programming assignemtn 3 2024

Uploaded by

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

Ass3 attempt2

Started on Thursday, 27 June 2024, 5:16 PM


State Finished
Completed on Thursday, 27 June 2024, 6:15 PM
Time taken 59 mins 7 secs
Grade 36.00 out of 75.00 (48%)
Question 1
Correct
Mark 1.00 out of 1.00

Flag question

Question text
How many times would “Hello World” be displayed when the following is
executed?
ShowHelloWorld
a=0
display “Hello World”
do
display “Hello World”
a=a+1
loop until a < 5
end
a.
none
b.
5
c.
6
d.
infinite
Feedback
The correct answer is: 6

Question 2
Correct
Mark 1.00 out of 1.00

Flag question

Question text
How many times would “Hello World” be displayed when the following is
executed?
ShowHelloWorld
a=0
display “Hello World”
do
display “Hello World”
loop until a < 5
end
a.
2
b.
infinite
c.
1
d.
none
Feedback
The correct answer is: infinite

Question 3
Correct
Mark 1.00 out of 1.00

Flag question

Question text
How many times would “Hello World” be displayed when the following is
executed?
ShowHelloWorld
a=0
display “Hello World”
do while a < 5
display “Hello World”
a=a+1
loop
end
a.
6
b.
5
c.
7
d.
none
Feedback
The correct answer is: 6

Question 4
Correct
Mark 1.00 out of 1.00

Flag question

Question text
How many times would “Hello World” be displayed when the following is
executed?
ShowHelloWorld
a=0
display “Hello World”
do while a < 5
display “Hello World”
loop
end
a.
5
b.
infinite
c.
none
d.
6
Feedback
The correct answer is: infinite

Question 5
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
How many times would “Programming is fun” be displayed when the
following is executed?
ProgrammingIsFun
x=2
y=3
do
x=x+1
do while y <=5
display “Programming is Fun”
y=y+2
loop
display “Programming is Fun”
loop until x = 6
display “Programming is Fun”
end
a.
7
b.
5
c.
6
d.
infinite
Feedback
The correct answer is: 7

Question 6
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
In a ____, the loop body executes at least one time because the loop control
variable is not tested until after one iteration.
a.
pre-test loop
b.
loop control
c.
post-test loop
d.
nested loop
Feedback
The correct answer is: post-test loop

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following code has been executed if
the user enters the following empNum 90008936, deptCode HT, annSal
45000, empnum 90008966, deptCode AY, annSal 85000, empNum
90008745, depCode KC, annSal 30000, empnum 0.
CalculateIncreases
~ As no sentinel has been suggested, an employee number of 0 will
terminate the program
display “Enter the employee number for the first employee”
enter empNum
totalIncAmt = 0
do while empNum <> 0
display “Enter the department code for this employee”
enter deptCode
display “Enter the current annual salary for this employee”
enter annSal
select case deptCode
case “AY”
incAmt = annSal * 0.06
case “HT”
incAmt = annSal * 0.063
case “KL”
incAmt = annSal * 0.069
case Other
incAmt = annSal * 0.058
endselect
annSal = annSal + incAmt
totalIncAmt = totalIncAmt + incAmt
display “Enter the employee number for the next employee”
enter empNum
loop
display “The total amount for annual increases is R”, totalIncAmt
end
a.
The total amount for annual increases is R9600
b.
The total amount for annual increases is R169930
c.
The total amount for annual increases is R10125
d.
The total amount for annual increases is R9675
Feedback
The correct answer is: The total amount for annual increases is R9675

Question 8
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following code has been executed if
the user enters totAmount - 5000 and monthAmount - 400.
CalculateSavings
finalAmount = 0
noMonths = 0
display “Provide the amount that Pule wants to save”
enter totAmount
display “The monthly amount that he is able to save”
enter monthAmount
do
if finalAmount < 1000 then
finalAmount = finalAmount * 1.07
else
finalAmount = finalAmount * 1.09
enif
finalAmount = finalAmount + monthAmount
noMonths = noMoths + 1
loop until finalAmount >= totAmount
display “Pule had to save “, noMonths, “ months to reach his goal”
end
a.
Pule had to save 8 months to reach his goal
b.
Pule had to save 9 months to reach his goal
c.
None of the above
d.
Pule had to save 10 months to reach his goal
Feedback
The correct answer is: Pule had to save 9 months to reach his goal

Question 9
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following code has been executed.
CompareLoop CompareLoop
a=1 a=1
b=2 b=2
do while a <> 5 do
a=a+1 a=a+1
b=b+2 b=b+2
loop loop until a <> 5
display “b = “, b display “b = “, b
end end
a.
b = 10 b = 8
b.
b=8b=8
c.
b = 10 b = 10
d.
b = 10 b = 4
Feedback
The correct answer is: b = 10 b = 4

Question 10
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following code has been executed.
ShowXAZ
x=5
y=7
for a = 1 to 12 step 5
do
z=a*x+y
y=y–1
x=x+1
loop y > 7
next a
display “x = “, x, “a = “, a, “z = “, z
end
a.
x= 7 a = 11 z = 42
b.
x= 9 a = 18 z = 122
c.
x= 8 a = 16 z =82
d.
x= 8 a = 11 z = 82
Feedback
The correct answer is: x = 8 a = 16 z =82

Question 11
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following do-until loop has been
executed.
ShowNumber
result = 0
count = 0
number = 2
do
result = result + number
count = count + 1
number = number + 2
loop until number >= 10
display “result = “, result, “count = “, count
end
a.
result = 100 count = 5
b.
result = 60 count = 5
c.
result = 20 count = 4
d.
none of the above
Feedback
The correct answer is: result = 20 count = 4

Question 12
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following do-until loop has been
executed.
ShowResults
result = 0
count = 0
number = 20
do
result = result + number
count = count + 1
number = number – 4
loop until number < 3
display “result = “, result, “count = “, count
end
a.
result = 20 count = 4
b.
result = 60 count = 5
c.
result = 100 count = 5
d.
none of the above
Feedback
The correct answer is: result = 60 count = 5

Question 13
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following do-while loop has been
executed if the user enters the itemPrice as 10.00, 49.99, 37.49, 22.00,
12.49, 10.99.
CalculateNumberOfItemsBought
noItems = 0
display “Enter the price for the first item”
enter itemPrice
totalPrice = itemPrice
do while totalPrice <= 120
noItems = noItems + 1
display “Enter the price for the next item”
enter itemPrice
totalPrice = totalPrice + itemPrice
loop
display “Angela could buy “, noItems, “items”
end
a.
Angela could buy 3 items
b.
Angela could buy 4 items
c.
Angela could buy 5 items
d.
Angela could buy 6 items
Feedback
The correct answer is: Angela could buy 4 items

Question 14
Correct
Mark 1.00 out of 1.00

Remove flag

Question text
Indicate what will be displayed after the following do-while loop has been
executed.
ShowAnswer
a=5
b=7
answer = 15
do while answer <= 47
answer = answer + a – b
a=a+6
b=b–1
loop
display “answer: “, answer
end
a.
answer: 48
b.
answer: 49
c.
answer: 50
d.
answer: 47
Feedback
The correct answer is: answer: 49

Question 15
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Indicate what will be displayed after the following do-while loop has been
executed.
ShowSum
a=5
b=7
do while sum <= 47
sum = sum – a + b
a=a–1
b=b+4
loop
display “sum: “, sum
end
a.
none of the above
b.
sum: 36
c.
sum: 60
d.
sum: 50
Feedback
The correct answer is: sum: 60

Question 16
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A do-while loop is as a fixed counter loop.
True
False
Feedback
The correct answer is 'False'.

Question 17
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A sentential value is a value that is not legitimate data value for a particular
problem, but it is proper type, that is used to check for a ‘stopping value’.
True
False
Feedback
The correct answer is 'True'.

Question 18
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A sentinel loop asks the user whether to continue on each iteration.
True
False
Feedback
The correct answer is 'True'.

Question 19
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Any do-until loop can be rewritten as a for-loop.
True
False
Feedback
The correct answer is 'False'.

Question 20
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Both the while loop and the for loop are examples of pre-test loops.
True
False
Feedback
The correct answer is 'False'.

Question 21
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Do-loop-until loops evaluate a conditional expression at the bottom of the
loop to determine whether another iteration will be allowed.
True
False
Feedback
The correct answer is 'False'.

Question 22
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Do-loop-until structure is most useful if code inside the loop does not have to
execute at least once.
True
False
Feedback
The correct answer is 'False'.
Question 23
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Do-while loops do not allow even one iteration if the pre-test evaluates to
false the first time it is encountered.
True
False
Feedback
The correct answer is 'True'.

Question 24
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Do-while loops evaluate a conditional expression at the entrance to the loop
body to determine whether control passes into it.
True
False
Feedback
The correct answer is 'False'.

Question 25
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Do-while loops is useful if code inside the loop have to execute at least once.
True
False
Feedback
The correct answer is 'False'.

Question 26
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A ____ relates parallel arrays.
a.
subscript
b.
key
c.
postscript
d.
superscript
Feedback
The correct answer is: subscript

Question 27
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A program contains an array that holds all the names of the days of the
week. Which of the following is true?
a.
The highest subscript is 7
b.
The highest subscript is 12
c.
The highest subscript is 6
d.
The lowest subscript is 1
Feedback
The correct answer is: The highest subscript is 6

Question 28
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A two-dimensional array contains two dimensions:
a.
size and scope
b.
breadth and height
c.
depth and width
d.
height and width
Feedback
The correct answer is: height and width

Question 29
Incorrect
Mark 0.00 out of 1.00

Flag question
Question text
An array can be used to replace ____.
a.
loops
b.
nested decisions
c.
methods
d.
records
Feedback
The correct answer is: nested decisions

Question 30
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

An array is a ____ of values in computer memory.


a.
accumulation
b.
set
c.
list
d.
record
Feedback
The correct answer is: list

Question 31
Correct
Mark 1.00 out of 1.00

Flag question

Question text
An array whose elements you can access using a single subscript is a ____
array.
a.
non-dimensional
b.
multi-dimensional
c.
single-dimensional
d.
one-dimensional
Feedback
The correct answer is: one-dimensional

Question 32
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Array elements all have the same ____ in common.
a.
memory location
b.
pointer
c.
value
d.
data type
Feedback
The correct answer is: data type

Question 33
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Each element in a two-dimensional array requires ____ subscript(s) to
reference it.
a.
four
b.
two
c.
one
d.
three
Feedback
The correct answer is: two

Question 34
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Every array has a ____ size.


a.
finite
b.
infinite
c.
constant
d.
variable
Feedback
The correct answer is: finite

Question 35
Correct
Mark 1.00 out of 1.00

Flag question

Question text
In a ____, items in a list are compared with each other in pairs.
a.
matrix sort
b.
shell sort
c.
quick sort
d.
bubble sort
Feedback
The correct answer is: bubble sort

Question 36
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text

Parallel arrays are most useful when value pairs have a ____ relationship.
a.
linked
b.
tiered
c.
indirect
d.
direct
Feedback
The correct answer is: indirect

Question 37
Correct
Mark 1.00 out of 1.00
Flag question

Question text
The number of elements in an array is called the ____ of the array.
a.
height
b.
depth
c.
width
d.
size
Feedback
The correct answer is: size

Question 38
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
What are the correct intermediate steps of the following data set when it is
being sorted with the bubble sort? 15,20,10,18
a.
15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20
b.
15,20,10,18 -- 15,10,20,18 -- 10,15,20,18 -- 10,15,18,20
c.
10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20
d.
15,10,20,18 -- 15,10,18,20 -- 10,15,18,20
Feedback
The correct answer is: 15,10,20,18 -- 15,10,18,20 -- 10,15,18,20

Question 39
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
What are the correct intermediate steps of the following data set when it is
being sorted with the Selection sort? 15,20,10,18
a.
15,20,10,18 -- 15,10,20,18 -- 10,15,20,18 -- 10,15,18,20
b.
15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20
c.
10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20
d.
15,10,20,18 -- 15,10,18,20 -- 10,15,18,20
Feedback
The correct answer is: 10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20

Question 40
Incorrect
Mark 0.00 out of 1.00

Remove flag

Question text
What would be the output of the following algorithm when the user enters the
array numbers as:
"ArraysAreFunToUseNot"
CountVowel
vowelCount = 0
for x = 0 to 19
select case charArray(x)
case “A”, “E”, “I”, “O”, “U”
vowelCount = vowelCount + 1
endselect
next x
display “There are/is “, vowelCount, “ vowel(s) in this array”
end
a.
There are/is 9 vowel(s) in this array
b.
There are/is 8 vowel(s) in this array
c.
There are/is 3 vowel(s) in this array
d.
There are/is 4 vowel(s) in this array
Feedback
The correct answer is: There are/is 3 vowel(s) in this array

Question 41
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A bubble sort is often considered the most efficient sorting method since it
must exchange items before the final location is known.
True
False
Feedback
The correct answer is 'False'.

Question 42
Incorrect
Mark 0.00 out of 1.00
Flag question

Question text
A parallel array is an array that stores another array in each element.
True
False
Feedback
The correct answer is 'True'.

Question 43
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
An element in an array need not have an initial value.
True
False
Feedback
The correct answer is 'False'.

Question 44
Correct
Mark 1.00 out of 1.00

Flag question

Question text
An insertion sort is another name for a bubble sort.
True
False
Feedback
The correct answer is 'True'.

Question 45
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Arrays cannot be used if you need to search for a range of values.
True
False
Feedback
The correct answer is 'False'.

Question 46
Incorrect
Mark 0.00 out of 1.00
Flag question

Question text
Arrays that are capable of holding the contents of a table with several rows
and columns, are known as two-dimensional arrays.
True
False
Feedback
The correct answer is 'False'.

Question 47
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
In every iteration of selection sort, the minimum element (considering
ascending order) from the unsorted subarray is picked and moved to the
sorted subarray.
True
False
Feedback
The correct answer is 'False'.

Question 48
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
It is advisable to sort the values of the elements in an array into a specific
sequence – ascending or descending order – according to a specific field(s).
True
False
Feedback
The correct answer is 'False'.

Question 49
Correct
Mark 1.00 out of 1.00

Flag question

Question text
It is relatively easy for people to keep track of arrays with more than three
dimensions.
True
False
Feedback
The correct answer is 'False'.

Question 50
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Like other variables, array variables can be declared and assigned initial
values at the same time.
True
False
Feedback
The correct answer is 'False'.

Question 51
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A sub procedure is valuable because it:
a.
limits the number of times the code can be accessed
b.
makes code easier to maintain
c.
splits the logic to solve a problem into small, manageable units
d.
Both a and b
Feedback
The correct answer is: Both a and b

Question 52
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Depending on the programming language being used, modules are also
known as ____ .
a.
procedures, functions, or containers
b.
subroutines, receptacles, or methods
c.
subroutines, procedures, or methods
d.
tasks, functions, or methods
Feedback
The correct answer is: subroutines, procedures, or methods

Question 53
Correct
Mark 1.00 out of 1.00

Flag question

Question text
From how many places in the code can a procedure be called?
a.
1
b.
2
c.
0
d.
As many times as needed
Feedback
The correct answer is: As many times as needed

Question 54
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
How many return statements are allowed in a Function Procedure?
a.
There is no limit.
b.
None of the above
c.
1
d.
2
Feedback
The correct answer is: There is no limit.

Question 55
Incorrect
Mark 0.00 out of 1.00

Remove flag

Question text
Provided the problem statement below, which of the following algorithms will
solve the problem?
A product price and the discount applicable to the product is entered. The
discount may never be more than 25%. If the discount is more than 25% the
user must re-enter the discount percentage. The amount due after the
discount have been applied must be displayed.
a.
Function CalcPercDiscount()
do
display “Enter the percentage discount that applies”
enter percDiscount
if percDiscount < 0 or percDiscount > 25 then
display “Invalid discount – please re-enter”
endif
loop until percDiscount >= 0 and percDiscount <= 25
return percDiscount

Function mainModule
display “Enter the price of the product”
enter price
discount = CalcPercDiscount()
amtDue = price – price * (discount / 100)
display “Amount due = R”, amtDue
end
b.
CalcPercDiscount()
do
display “Enter the percentage discount that applies”
enter percDiscount
if percDiscount < 0 or percDiscount > 25 then
display “Invalid discount – please re-enter”
endif
loop until percDiscount >= 0 and percDiscount <= 25
return percDiscount

mainModule
display “Enter the price of the product”
enter price
discount = CalcPercDiscount(percDiscount)
amtDue = price – price * (discount / 100)
display “Amount due = R”, amtDue
end
c.
Function CalcPercDiscount()
do
display “Enter the percentage discount that applies”
enter percDiscount
if percDiscount < 0 or percDiscount > 25 then
display “Invalid discount – please re-enter”
endif
loop until percDiscount >= 0 and percDiscount <= 25
return percDiscount

mainModule
display “Enter the price of the product”
enter price
discount = CalcPercDiscount()
amtDue = price – price * (discount / 100)
display “Amount due = R”, amtDue
end
d.
Function CalcPercDiscount()
do
display “Enter the percentage discount that applies”
enter percDiscount
if percDiscount < 0 or percDiscount > 25 then
display “Invalid discount – please re-enter”
endif
loop until percDiscount >= 0 and percDiscount <= 25
return percDiscount

mainModule
display “Enter the price of the product”
enter price
discount = CalcPercDiscount(percDiscount)
amtDue = price – price * (discount / 100)
display “Amount due = R”, amtDue
end
Feedback
The correct answer is:
Function CalcPercDiscount()
do
display “Enter the percentage discount that applies”
enter percDiscount
if percDiscount < 0 or percDiscount > 25 then
display “Invalid discount – please re-enter”
endif
loop until percDiscount >= 0 and percDiscount <= 25
return percDiscount

mainModule
display “Enter the price of the product”
enter price
discount = CalcPercDiscount(percDiscount)
amtDue = price – price * (discount / 100)
display “Amount due = R”, amtDue
end

Question 56
Correct
Mark 1.00 out of 1.00

Remove flag

Question text
Provided the problem statement below, which of the following algorithms will
solve the problem?
A student name and three test marks are entered, the average mark must be
calculated and it must be determined if the student passes or fails (mark
equal or above 50%). The student name, average and result must be
displayed on screen.
a.
Function CalcAve (valTest1, valTest2, valTest3)
return (valTest1 + valTest2 + valTest3) / 3

Function DetermineResults(valAve)
if valAve < 50 then
message = “fail”
else
message = “pass”
endif
return message

ShowResults
display “Enter the student name”
enter studentName
display “Enter the first test mark”
enter testMark1
display “Enter the second test mark”
enter testMark2
display “Enter the third test mark”
enter testMark3
average = CalcAve()
display “The average mark for “, studentName, “ is “, average
display “This student will “, DetermineResults()
end
b.
Function CalcAve (valTest1, valTest2, valTest3)
return (valTest1 + valTest2 + valTest3) / 3

Function DetermineResults(valAve)
if valAve < 50 then
message = “fail”
else
message = “pass”
endif
return message

ShowResults
display “Enter the student name”
enter studentName
display “Enter the first test mark”
enter testMark1
display “Enter the second test mark”
enter testMark2
display “Enter the third test mark”
enter testMark3
average = CalcAve(valTest1, valTest2, valTest3)
display “The average mark for “, studentName, “ is “, average
display “This student will “, DetermineResults(message)
end
c.
Function CalcAve ()
return (valTest1 + valTest2 + valTest3) / 3

Function DetermineResults()
if valAve < 50 then
message = “fail”
else
message = “pass”
endif
return message

ShowResults
display “Enter the student name”
enter studentName
display “Enter the first test mark”
enter testMark1
display “Enter the second test mark”
enter testMark2
display “Enter the third test mark”
enter testMark3
average = CalcAve (valTest1, valTest2, valTest3)
display “The average mark for “, studentName, “ is “, average
display “This student will “, DetermineResults(message)
end
d.
CalcAve (valTest1, valTest2, valTest3)
return (valTest1 + valTest2 + valTest3) / 3

DetermineResults(valAve)
if valAve < 50 then
message = “fail”
else
message = “pass”
endif
return message

ShowResults
display “Enter the student name”
enter studentName
display “Enter the first test mark”
enter testMark1
display “Enter the second test mark”
enter testMark2
display “Enter the third test mark”
enter testMark3
average = CalcAve (valTest1, valTest2, valTest3)
display “The average mark for “, studentName, “ is “, average
display “This student will “, DetermineResults(message)
end
Feedback
The correct answer is:
Function CalcAve (valTest1, valTest2, valTest3)
return (valTest1 + valTest2 + valTest3) / 3

Function DetermineResults(valAve)
if valAve < 50 then
message = “fail”
else
message = “pass”
endif
return message

ShowResults
display “Enter the student name”
enter studentName
display “Enter the first test mark”
enter testMark1
display “Enter the second test mark”
enter testMark2
display “Enter the third test mark”
enter testMark3
average = CalcAve(valTest1, valTest2, valTest3)
display “The average mark for “, studentName, “ is “, average
display “This student will “, DetermineResults(message)
end

Question 57
Correct
Mark 1.00 out of 1.00

Remove flag

Question text
Provided the problem statement below, which of the following algorithms will
solve the problem?
Reginald went to a shop to buy a number of fruit bars. The amount due must
be calculated and 14% vat added. The calculated value must be displayed
on the screen.
a.
CalcAmntDue (valNum, valPrice)
Return (valNum * valPrice * 1.14)

ShoppingProgram
display “Enter the number of fruit bars bought”
enter numberItems
display “Enter the price of a fruit bar”
enter price
amtDue = CalcAmntDue (numItems, price)
display “The amound due is R”, amtDue
end
b.
Function CalcAmntDue (valNum, valPrice)
Return (valNum * valPrice * 1.14)

ShoppingProgram
display “Enter the number of fruit bars bought”
enter numberItems
display “Enter the price of a fruit bar”
enter price
amtDue = CalcAmntDue (numItems, price)
display “The amound due is R”, amtDue
end
c.
Function CalcAmntDue ()
Return (valNum * valPrice * 1.14)

ShoppingProgram
display “Enter the number of fruit bars bought”
enter numberItems
display “Enter the price of a fruit bar”
enter price
amtDue = CalcAmntDue (numItems, price)
display “The amound due is R”, amtDue
end
d.
Function CalcAmntDue (valNum, valPrice)
Return (valNum * valPrice * 1.14)

ShoppingProgram
display “Enter the number of fruit bars bought”
enter numberItems
display “Enter the price of a fruit bar”
enter price
amtDue = CalcAmntDue (valNum, valPrice)
display “The amound due is R”, amtDue
end
Feedback
The correct answer is:
Function CalcAmntDue (valNum, valPrice)
Return (valNum * valPrice * 1.14)

ShoppingProgram
display “Enter the number of fruit bars bought”
enter numberItems
display “Enter the price of a fruit bar”
enter price
amtDue = CalcAmntDue (numItems, price)
display “The amound due is R”, amtDue
end

Question 58
Correct
Mark 1.00 out of 1.00

Flag question

Question text
The methodology where code is broken into small, logical procedures is
called:
a.
modular programming
b.
functional programming
c.
granular programming
d.
event-driven programming
Feedback
The correct answer is: modular programming

Question 59
Correct
Mark 1.00 out of 1.00

Flag question

Question text
The process of breaking down a large program into modules is called ____.
a.
caching
b.
decomposing
c.
modularization
d.
fragmentation
Feedback
The correct answer is: modularization

Question 60
Correct
Mark 1.00 out of 1.00

Remove flag

Question text
When a program has several modules calling other modules, programmers
often use a program ____, which operates similarly to an organizational chart,
to show the overall picture of how modules are related to one another.
a.
data diagram
b.
tree chart
c.
flow chart
d.
hierarchy chart
Feedback
The correct answer is: hierarchy chart

Question 61
Incorrect
Mark 0.00 out of 1.00

Remove flag

Question text
When using a procedure the calling code sends data via the:
a.
formal parameter to the actual argument of the procedure
b.
actual parameter to the formal argument of the procedure
c.
formal argument to the actual parameter of the procedure
d.
actual argument to the formal parameter of the procedure
Feedback
The correct answer is: actual argument to the formal parameter of the
procedure

Question 62
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Which part of a function procedure declaration statement is optional?
a.
Datatype
b.
Parameters
c.
Private
d.
Function
Feedback
The correct answer is: Parameters

Question 63
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Which statement will send the value generated by a function procedure,
called CalculateTax, back to the calling code?
a.
Both a and b
b.
CalculateTax = Sales*0.08
c.
Return Sales*0.08
d.
Return CalculateTax (Sales*0.08)
Feedback
The correct answer is: Both a and b

Question 64
Incorrect
Mark 0.00 out of 1.00

Remove flag

Question text
A function always receives and returns value parameters.
True
False
Feedback
The correct answer is 'True'.

Question 65
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A function can act like an expression in an assignment statement.
True
False
Feedback
The correct answer is 'False'.

Question 66
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A function must have an assigned data type.
True
False
Feedback
The correct answer is 'True'.
Question 67
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A function procedure must have a Return statement.
True
False
Feedback
The correct answer is 'False'.

Question 68
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A hierarchy chart contains details of each module and how the modules are
related.
True
False
Feedback
The correct answer is 'True'.

Question 69
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A parameter is used to send information into a procedure, and an argument
is used to carry information out of a procedure.
True
False
Feedback
The correct answer is 'True'.

Question 70
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
A parameter may not contain the address of an answer when dealing with a
sub-procedure.
True
False
Feedback
The correct answer is 'False'.

Question 71
Correct
Mark 1.00 out of 1.00

Flag question

Question text
An argument list can not be empty.
True
False
Feedback
The correct answer is 'False'.

Question 72
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
If a function contains an if statement, it may contain more than one return
statement in different parts of the if statement.
True
False
Feedback
The correct answer is 'False'.

Question 73
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Large and complex applications can be broken down into smaller, more
manageable tasks.
True
False
Feedback
The correct answer is 'False'.

Question 74
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Large and complex programs can be divide into independently developed
modules.
True
False
Feedback
The correct answer is 'True'.

Question 75
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Lines of code that perform a specific task that is repeated often would
typically be coded as a separate procedure.
True
False
Feedback
The correct answer is 'False'.

Finish review
P r e v i o u s a c t i v i t y Assessment 2
Jump to... Jump to... Announcements
Additional Resources Assessment 1 Assessment 2
Assessment 4 Examination Online Learning
Assessment Information Additional resources
Chapter 1 Chapter 2 Chapter 3 Chapter
4 Chapter 5 Chapter 6 Chapter 7
Chapter 8 Chapter 9 Communication with Lecturers
Communication with fellow Students Copied Assessments
N e x t a c t i v i t y Assessment 4
Contact us



Follow us





You are logged in as DANIEL TEBOGO MATLALA (Log out)


Data retention summary
Get the mobile app
Get the mobile app
This page is: General type: incourse. Context Quiz: Assessment 3 (context id 26698046).
Page type mod-quiz-review.

You might also like