Vai al contenuto

Challenge 2011-12

Easy Challenge 1

Write a program to calculate the value of a savings account.
The input should be the initial value invested, the number of years the saving will be for, and an interest rate percent.
The output is the value of the savings at the end of the term.

Remember compound interest!

Easy Challenge 2

Get the Turtle to draw a Christmas tree or other festive shape (e.g. a star).

Discussione Intermediate Challenge

Import the following code sample (XMW920), there are a number of errors – fix these.
Most of the errors prevent the sample compiling so it should be relatively easy to identify these from the compiler error reports.
Click on these to take you to the offending line.

There is also one other error that allows the code to run, but doesn’t work as expected, so you will need to test the code.

When all the errors are detected, the code works fine, but it is not ‘good’ code.
It jumps all-over-the-place using GoTo statements and is very hard to follow.

The remainder of this challenge is to rewrite the code with a good structure using no GoTo statements if possible, using any methods you think make the code clearer (possibly Arrays, While or Subroutines etc), also comment it.

Advanced Challenge 1

Write a program or sequence of programs to discover the largest integer that SmallBaic can handle before it crashes.
Put another way, what is the value for ‘largeNumber’ written out below, such that the following line adding 1 to it causes a crash.

TextWindow.WriteLine(“This number is OK “+largeNumber)
largeNumber = largeNumber + 1

Supplemental, what is the significance of this number?

Advanced Challenge 2

How many positive integer solutions are there to this equation?

1000+x+y+z = x*y*z

Each solution is a set of values for x, y and z that satisfy the equation, such as x=10, y=4, z=26.

How fast can you get SmallBasic to calculate the answer?

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.