In this task, you're going to use your programming skills to print the words to the children's song Ten Green Bottles.
Here is a reminder of the commands you might need for this task. As the course progresses, you will get fewer of these reminders.
PRINT - text needs to be put in speech marks, e.g. PRINT "Hello", numbers don't, e.g. PRINT 10 or PRINT A (where A is a variable). Putting a semi-colon (;) at the end of the print command - e.g. PRINT "Hello"; - will cause the next thing that you print to carry on on the same line.
INPUT - e.g. INPUT "What is your name? "; A$ will ask the question and store the answer in the variable called A$
FOR - repeats a section of your program a number of times - e.g. FOR N = 1 TO 10 will repeat 10 times, counting with N from 1 to 10. If you don't want to count in 1s, you can add STEP - e.g. FOR N = 5 TO 100 STEP 5 (to count up to 100 in 5s) or FOR N = 10 TO 1 STEP -1 (to count from 10 down to 1). You don't need to use N - it's just a programmers habit, like using x in algebra; any valid variable name will do.
NEXT - goes after FOR, at the end of the section that you want to repeat, e.g.
FOR N = 1 TO 10
will print the word Hello ten times. You don't have to count upwards or start at 1, and you can use the variable that you're using as the counter. The size of the steps is controlled using the STEP keyword (and the step size can be negative). The following program, for example, will print the numbers from 10 to 100, going up in 10s:
FOR N = 10 TO 100 STEP 10
Comments - these are lines in your program that don't do anything. They are like labels and are usually use to remind you (or someone else looking at your program) what it does. Any line that begins with an apostrophe is treated as a comment, e.g. ' My First Program.
Your task is to produce a program to print the words to the song Ten Green Bottles. Your program should:
be efficient and use a loop - it shouldn't just PRINT the whole song
include the correct number of bottles at each stage, counting down from 10 to 1
consider how to lay out the words to make the song clear and easy to read
You can use any other programming tricks you've learnt to improve the program. If you've been reading ahead, you could use an array to display the number in words instead of digits - e.g. ten green bottles instead of 10 green bottles.