Sunday, November 22, 2009

scratch - Calculator simulator (addition)

Our task in Control Tech was to work in pairs and do the same task both on scratch and Etoys. My partner was Mr.Unknown and we had the task of creating a calculator type program that simulates two numbers for addition and we would need to input an answer for that and then it would tell us if our answer was right or wrong.My job was to do this on scratch.

I did this task by creating 4 variables, they were for the 1st number, 2nd number, actual answer and our own answer. I started by making the 1st and 2nd number variables generate random numbers each time i clicked the "new sum" sprite that i created.

I then created an answer sprite and when clicked it would either switch to a costume that said incorrect or correct depend if you were right or wrong. This was made possible by the "If" command; If input number= 1st number + 2nd number "switch to costume 2" which would mean correct and if the incorrect it was exactly the same except i used the "Not" command ( If "Not" input number= 1st number + 2nd number "switch to costume 3". If the answer was wrong the answer variable would show the right answer.

I also made the "New Sum" sprite reset everything by using broadcast. So when clicked it would broadcast "reset" and then i used the command "When i receive :reset" then set number variables to random, answer and input answer variable to 0 and "answer" sprite back to costume 1 which read answer.

I did not find this task difficult at all because scratch is an easy to use program with its simple layout and lego-like scripts.

My "answer" sprite script
Before answer check:

Click this link for the Etoys version of this; By Mr.Uknown :

1 comment: