Designing, creating and refining algorithms
3
0/6

An environmental monitoring station wants an algorithm to analyse river water acidity over a 7-day period.

Write an algorithm in pseudocode or a high-level programming language that implements the following design requirements:

  • Initialize a counter for 'acidic days' to 0.
  • Initialize a running total for the pH of 'safe days' to 0.0.
  • Loop 7 times (representing days 1 to 7).
  • In each iteration, prompt the user to input the pH level (as a decimal value) for the current day.
  • If the pH level is strictly less than 6.0, output 'Day [number]: Acidic' (where [number] is the current day number) and add 1 to the acidic days counter.
  • Otherwise, output 'Day [number]: Safe' and add the current pH level to the running total of safe days' pH.
  • After the loop finishes:
    • Output the total number of acidic days with an appropriate message.
    • Calculate and output the average pH of the safe days. To prevent division by zero, the average must be output as 0.0 if there were no safe days.
[6]

Designing, creating and refining algorithms Questions

Practise OCR GCSE Computer Science Designing, creating and refining algorithms with exam-style questions for GCSE Computer Science. 50 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Designing, creating and refining algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Designing, creating and refining algorithms