Uploaded by faheemyeasingazi

algorithm sum updated

advertisement
1. A town contains 5000 houses. Each house owner must pay tax based on the value of the house.
Houses over $200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of their value in
tax and houses over $50 000 pay 1% of their value in tax. All others pay no tax. Write an algorithm
to solve this problem in pseudo code
2. Write an algorithm which takes temperatures input over a 100 days period (once per day) and
outputs the number of days when the temperature was below 20C and the number of days when
the temperature was 20C and above.
3. A shop sells books, maps and magazines. Each item is identified by a unique 4 – digit code. All books
have a code starting with 1, all maps have a code starting with 2 and all magazines have a code
starting with 3. The code 9999 is used to end the algorithm.
Write an algorithm in the form of pseudo code which inputs the codes for all items in stock and
outputs the number of books, number of maps and the number of magazines in stock. Include any
validation checks needed.
4. A procedure (subroutine) called BELT exists to take one box and put it on a conveyor
belt. Write an algorithm, using this procedure, to put 50 boxes on the conveyor belt.
5. Using pseudo code or otherwise, write an algorithm which will take information about each
transaction at a supermarket till, calculate and output
• the number of sales,
• the number of refunds,
• the total amount of money for n number of items.
6. Using pseudocode or otherwise, write an algorithm that will input 25 marks and output the
number of DISTINCTION, MERIT, PASS or FAIL grades.
A mark greater than 69 will get a DISTINCTION, a mark between 69 and 60 (inclusive) will get a MERIT
and a mark between 59 and 50 (inclusive) will get a PASS.
7. A formula for calculating the body mass index (BMI) is:
weight in kilograms
BMI = weight / ((height in metres) x (height in metres))
Calculate the BMI for a person whose weight is 80kg and height is 2 metres.
[1]
(b) Using pseudocode or otherwise, write an algorithm that will input the ID, weight (kg) and
height (m) of 30 students, calculate their body mass index (BMI) and output their ID,
BMI and a comment as follow:
A BMI greater than 25 will get the comment ‘OVER WEIGHT’, a BMI between 25 and
19 (inclusive) will get ‘NORMAL’ and a BMI less than 19 will get ‘UNDER WEIGHT’.
Download