Programming Problems SU 4
Programming Problems SU 4
Programming Problems SU 4
Construct a solution algorithm for the following programming problems. Your solution should
contain:
a defining diagram
a pseudocode algorithm
a desk check of the algorithm.
1 Design an algorithm that will receive two integer items from a terminal operator, and
display to the screen their sum, difference, product and quotient. Note that the quotient
calculation (first integer divided by second integer) is only to be performed if the
second integer does not equal zero.
2 Design an algorithm that will read two numbers and an integer code from the screen.
The value of the integer code should be 1, 2, 3 or 4. If the value of the code is 1,
compute the sum of the two numbers. If the code is 2, compute the difference (first
minus second). If the code is 3, compute the product of the two numbers. If the code is
4, and the second number is not zero, compute the quotient (first divided by second). If
the code is not equal to 1, 2, 3 or 4, display an error message. The program is then to
display the two numbers, the integer code and the computed result to the screen.
3 Design an algorithm that will prompt the user for a student number and the student's
exam mark out of 100. Your program is then to match the exam mark to a letter grade
and print the student number and grade on the screen. Calculate the letter grade as
follows:
4 Design an algorithm that will receive the weight of a parcel and determine the delivery
charge for that parcel. Calculate the charges as follows:
5 Design an algorithm that will prompt a terminal operator for the price of an article and a
pricing code. Your program is then to calculate a discount rate according to the pricing
code and print to the screen the original price of the article, the discount amount and
the new discounted price. Calculate the pricing code and accompanying discount
amount as follows:
if the pricing code is Z, the words 'No discount' are to be printed on the screen. If the
pricing code is not H, F, T, Q or Z, the words 'Invalid pricing code' are to be printed.
Design an algorithm that will accept the cost of a building and calculate and display
the architect's fee.
Loans in excess of R100000 are not allowed. Design an algorithm that will read a
loan amount and compute and print the required deposit.
8 Design an algorithm that will receive a date in the format dd/mm/yyyy (for example,
21/07/2003) and validate it as follows:
9 The tax payable on taxable incomes for employees in a certain country is set out in the
following table:
From R29 500. 00-R45 787.99 R8656.00 plus 46 cents for each R in excess of R29500.00
R45 788. 00 and over R11179.00 plus 60 cents for each R in excess of
R45788.00
Design an algorithm that will read as input the taxable income amount and calculate
and print the tax payable on that amount.
10 A transaction record on a sales commission file contains the retail price of an item sold,
a transaction code that indicates the sales commission category to which an item can
belong, and the employee number of the person who sold the item. The transaction
code can contain the values S, M or L, which indicate that the percentage commission
will be 5%, 7% or 10%, respectively. Construct an algorithm that will read a record on
the file, calculate the commission owing for that record, and print the retail price,
commission and employee number.