Pseudocode Extra Support
Pseudocode Extra Support
PSEUDOCODE
Q2.Using pseudocode, or otherwise, write an algorithm that will input the hourly
temperatures for one day in Centigrade and print out in Fahrenheit
• the maximum temperature
• the minimum temperature
• the average temperature for that day.
The rail network consists of 10 stations. The fare between each station is $2. There is a
10% discount when 3 or more passengers travel together. Tickets can be purchased at any
station using automated terminals.
Using pseudocode, or otherwise, write an algorithm for the automated terminals to:
input the starting station number, the destination station number and the number of
passengers
calculate the total fare and output the amount to be paid
calculate the change (if any)
issue the rail ticket(s) and change
Q4.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.
Prepared by: Zainab Shabbir
Q5.A school uses a computer to store student marks obtained in an end of term
mathematics exam. There are 150 students doing the exam and the maximum mark is
100.
Write an algorithm, using pseudocode or otherwise, which
inputs the marks for all students
checks if each mark is in the correct range and, if not, the mark is re-input
outputs the smallest mark
outputs the highest mark
outputs the average mark for the exam.
Q6. A formula for calculating the body mass index (BMI) is:
Calculate the BMI for a person whose weight is 80kg and height is 2 meters.
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 follows:
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’.
Q7.Temperatures (°C) are being collected in an experiment every hour over a 200
hour period.
Write an algorithm, using pseudocode or otherwise, which inputs each temperature and
outputs
how many of the temperatures were above 20°C
how many of the temperatures were below 10°C
the lowest temperature that was input
Q8.A company has 5000 CDs, DVDs, videos and books in stock. Each item has a unique
5-digit code with the first digit identifying the type of item, i.e.
1 = CD
2 = DVD
3 = video
4 = book
For example, for the code 15642 the 1 identifies that it is a CD, and for the code 30055
the 3 identifies that it is a video.
Prepared by: Zainab Shabbir
Write an algorithm, using pseudocode or otherwise, which inputs the Distance Travelled
(km) and the Fuel Used (litres) for 1000 cars. The Fuel Economy for each car is then
calculated and the following outputs produced:
• Fuel Economy for each car
• average (mean) Fuel Economy for all of the cars input
• the best Fuel Economy (i.e. highest value)
• the worst Fuel Economy (i.e. lowest value)
Q12. A customer wants to compare prices of 1000 items sold in two supermarkets
(price1 and price2).
Write an algorithm, using pseudocodeora flowchart, which:
inputs the two prices for all 1000 items
outputs how many items were more expensive in supermarket 1
outputs how many items were more expensive in supermarket 2
outputs the largest price difference
Q13. 5000 numbers are being input which should have either 1 digit (e.g. 5), 2 digits (e.g.
36),3 digits (e.g. 149) or 4 digits (e.g. 8567).
Write an algorithm, using pseudocode or flowchart only, which
inputs 5000 numbers
outputs how many numbers had 1 digit, 2 digits, 3 digits and 4 digits
outputs the % of numbers input which were outside the range