## Exercises (algorithm of discounting)

This is one example that I took from http://xover4.jkt.3d.x.indowebster.com/download/51/42b182384731a41bffceb903334d20d8.pdf

page 28, about the algorithm of discounting

Algorithm Giving Discounts

{inputted total shopping purchases. 10% discount is given provided that the total expenditure of at least 100,000, -. Algorithms provide the amount of output obtained and the total discount to be paid by the buyer.}

{inputted total shopping purchases. 10% discount is given provided that the total expenditure of at least 100,000, -. Algorithms provide the amount of output obtained and the total discount to be paid by the buyer.}

Declaration:

shopping: integer

shopping: integer

discounts, total: real

Description

read (shopping)

discount <- 0 {initialization}

if spending> = 100000 then

discount <- 0.1*shopping

end if

total of <- shopping – discount

write (discount, total)

read (shopping)

discount <- 0 {initialization}

if spending> = 100000 then

discount <- 0.1*shopping

end if

total of <- shopping – discount

write (discount, total)

above algorithm can be described by the flowchart below :

The following output comes out if we are spending a total of 25 000 or less than 100 000

while the flowchart below, is the output that comes out of the expenditure is greater than or equal to 100 000

Advertisements