Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scratch 1.4: Beginner's Guide

You're reading from   Scratch 1.4: Beginner's Guide Learn to program while creating interactive stories, games, and multimedia projects using Scratch

Arrow left icon
Product type Paperback
Published in Jul 2009
Publisher Packt
ISBN-13 9781847196767
Length 264 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Time for action – calculate interest on lump sum


For this calculation, we will allow the user to set the interest rate, but we'll assume a static starting amount of $15,000. You decide whether or not you want to calculate dollars, candy bars, pine cones, or something else entirely.

The formula to calculate simple interest is:

Interest Earned = Principal Amount * Interest Rate * Time

  1. Add a new sprite to the stage. Feel free to choose any sprite you want, but I'm going to select the fantasy13 sprite from the d folder. Name the sprite Lump, as in lump sum.

  2. Create three new for this sprite only variables for the Lump sprite, named lumpSum, interestEarned, and interestRate.

  3. Build the calculation for the Lump sprite. Add the when key pressed block to the Lump sprite's script area. Select the up arrow from the drop-down list.

  4. From the Variables palette, add the set to block to the when key pressed block. Select interestEarned from the variables list.

  5. First, calculate the interest on 15,000 for a time...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image