(a) Introduction
You need to write a Blockly program to solve a simple problem. Use computational
thinking to help you design a solution and implement it using Blockly.
(b) The problem
When given a positive number X, which is the sum of odd sequence 1,3,5....,X?
Your Blockly program prompts the user to give you a number by saying "Enter a
number". Let's call this number X. You then calculate 1+3+5+... + X, and report the
result.
Here are a few example scenarios that you need to consider:
1. If the user gives you a number 5, your program should say:
The odd total from 1 to 5 is 9.
2. If the user gives you a number 10, your program should say:
The odd total from 1 to 10 is 25.
3. If the user gives you zero or a negative number, your program should say:
Invalid data. Please enter a positive number and prompt the user to
provide you with another number.
Now, let's recall some of the techniques of computational thinking.
1. Decomposition: How many different parts are there?
2. Pattern recognition: Are you able to see a pattern for your solutions?
1+3
1+3+5
1+3+5+7
1+3+5+7+9
...
3. Algorithm design: Which Blockly tools will be useful? Variable? Decision? Loop?
(Do not use a formula as a solution!!)
(Warning: The Blockly may give you a response that you are
correct or wrong, please ignore it, and the project will be
graded manually!)