Page 59 - My Own Workbook for CSEC Information Technology Examinations
P. 59

My Own Workbook for CSEC® Information Technology Examinations
FURTHER PRACTICE LOOPS: Count-controlled (FOR Loop)
37. Write a program to read a positive integer N, followed by N integer values. For these N values, count and print the number of zero and non-zero values included.
38. Modify the program in Q37 to compute the average of all even numbers between 1 and N inclusive. Perform any necessary validation.
39. A certain account at a bank earns compound interest on a yearly basis and has no deposits or withdrawals. The balance after a year has passed is given by the formula:
this year’s balance = last year’s balance x (1 + Interest Rate)
where Interest Rate is given as a decimal fraction (for example, 25% must be entered as 0.25)
Write a program that prompts for and accepts the interest rate as a decimal, the number of years to compute interest for, and the starting balance. It should compute and display the balance, including the interest, after N years have passed.
40. A program is required to print a list of all numbers between 1 and 1000 that are divisible by BOTH 4 and 8.
41. What is printed by the following algorithm when 4 is input for the value of A?
42. A fitness trainer charges $25.00 per session. A maximum of seven sessions can be done daily. A program is required to prompt for and accept the number of sessions worked each day in a 5-day work week and calculate how much money is earned for that week. Only valid values should be
accepted for the number of sessions worked.
LOOPS: Condition-controlled (REPEAT and WHILE Loops)
43. Write a program to implement the division function of a calculator using integer division. The program should accept the dividend (the number being divided, and a non-zero divisor. The program should carry out the division operation and print output as follow:
40/3 = 13 remainder
44. A program is required to read the scores obtained by students on a test. The set of input values is finished when the user enters -1. The program should print out the average of all students scoring scoring 80 or more.
107
READ A
FOR B = 1 TO A DO
BEGINC = A - B
Z = 5 * C- B
END PRINT Z
Copyrighted material. All rights reserved.
IT-book-edited-8,3x11,7.indd 110
9/11/18 7:25 PM
DO NOT COPY THIS PAGE DO NOT COPY THIS PAGE DO NOT COPY THIS PAGE


































































































   57   58   59   60   61