Question 6

OCR Computer Science June 2024 Algorithms and problem solving (H046-02)AS8 marks

On the specification

2.2 Problem solving and programming
Question text

6 A program needs writing to allow a user to play the game fizz buzz. The rules are: • the user enters the numbers from 1 to 100 in turn • if the number is exactly divisible by 3 the user enters “fizz” instead of the number • if the number is exactly divisible by 5 the user enters “buzz” instead of the number • if the number is exactly divisible by both 3 and 5 the user enters “fizz buzz” instead of the • the game will continue even if a wrong answer has been input until 100 is reached. For example, the first 10 numbers will be: 1 2 fizz 4 buzz fizz 7 8 fizz buzz The program needs to: • repeatedly allow the user to enter each number, or word(s) one at a time • output a suitable message if the input is incorrect, telling the user the correct number or correct word. For example, “Incorrect, the answer is 4” or “Incorrect, the answer is fizz buzz”. Write this algorithm using pseudocode or program code. [8]