0% found this document useful (0 votes)
30 views4 pages

Pseudocode Extra Support

The document provides 14 questions asking to write pseudocode algorithms to solve various problems. The problems include checking number ranges, converting temperatures, calculating fares on a rail network, sorting exam grades, calculating BMI, tracking temperatures and inventory, comparing prices, validating number of digits, and monitoring greenhouse sensors.

Uploaded by

Zainab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Pseudocode Extra Support

The document provides 14 questions asking to write pseudocode algorithms to solve various problems. The problems include checking number ranges, converting temperatures, calculating fares on a rail network, sorting exam grades, calculating BMI, tracking temperatures and inventory, comparing prices, validating number of digits, and monitoring greenhouse sensors.

Uploaded by

Zainab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Prepared by: Zainab Shabbir

PSEUDOCODE

Q1 .Write an algorithm, using pseudocode or otherwise, which;


• inputs 50 numbers
• checks whether each number is in the range 1000 to 9999
• outputs how many of the input numbers were out of range
• outputs the percentage of input numbers which were out of range.

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.

Q3.The following diagram shows a rail network.

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, that


Inputs the codes for all 5000 items
Validates the input code
Calculates how many CDs, DVDs, videos and books are in stock
Outputs the four totals.
Q9. Fuel economy for a car is found using the formula:

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)

Q10.Customers can withdraw cash from an Automatic Teller Machine (ATM).


withdrawal is refused if amount entered > current balance
withdrawal is refused if amount entered > daily limit
if current balance < $100, then a charge of 2% is made
if current balance $100, no charge is made
Write an algorithm which inputs a request for a sum of money, decides if a
withdrawal can be made and calculates any charges. Appropriate output messages should
be included.

Q11.The manufacturing cost of producing an item depends on its complexity. A


company manufactures three different types of item, with costs based on the following
calculations:
Item type 1: item cost = parts cost * 1.5
Item type 2: item cost = parts cost * 2.5
Item type 3: item cost = parts cost * 5.0
The company makes 1000 items per day.
Write an algorithm, using pseudocode, flowchart or otherwise, which
inputs the item type and parts cost of each item
outputs the item cost for each item
calculates and outputs the average (mean) item cost per day (based on 1000 items
being made).
Prepared by: Zainab Shabbir

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

Q14. A greenhouse is being monitored by a computer using 2 sensors.


SENSOR1 measures the temperature and SENSOR2 measures oxygen levels.
If the temperature exceeds 45°C or oxygen levels fall below 0.19, then an error
message is output by the computer.
Write an algorithm, using pseudocode or flowchart only, which
inputs both sensor readings
checks the sensor input values and outputs a warning message if either are out
of range
continues monitoring until the <ESCAPE> key is pressed

You might also like