Constructs

EasyMediumHard
123456789101112131415161718192021222324252627282930
Question 20
Medium

A program is being developed to monitor daily ozone concentration levels in ppm and calculate the bulk order cost of replacing active carbon filter units in an industrial HVAC system. It displays each ozone reading stored in an array of measurements.

  • It sums up the prices of all filter replacement units entered by the user, until the user enters 0.
  • It then calculates a discount. When the total cost is over £150.00, the bulk discount rate is 12%. Otherwise, the discount rate is 4%.

Program Code

1: BULK_LIMIT = 150.00
2: ozone_readings = [0.045, 0.051, 0.038, 0.062, 0.040]
3: total_filter_cost = 0.0
4: print("Daily Ozone Concentrations (ppm):")
5: for reading in ozone_readings:
6:     print(str(reading) + " ppm")
7: filter_price = float(input("Enter carbon filter unit cost (0 to finish): "))
8: while filter_price != 0.0:
9:     total_filter_cost = total_filter_cost + filter_price
10:    filter_price = float(input("Enter carbon filter unit cost (0 to finish): "))
11: if total_filter_cost > BULK_LIMIT:
12:    discount_rate = 0.12
13: else:
14:    discount_rate = 0.04
15: final_cost = total_filter_cost * (1.0 - discount_rate)
16: print("Total cost after bulk discount: £" + str(final_cost))

Task

Identify the code features requested below from the program snippet shown above:

a.

Name of a constant used in the program

[1]
b.

Name of an array used in the program

[1]
c.

Line number of an initialisation of a variable with a real number

[1]
d.

Line numbers for a selection construct

[1]
e.

Line numbers for a repetition construct (condition-controlled loop)

[1]
f.

Line numbers for an iteration construct (count-controlled/collection loop)

[1]
g.

Line number for an instruction that outputs information to the screen

[1]

Constructs Questions

  1. GCSE
  2. /Computer Science
  3. /Constructs