Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Chapter 8 Exercise 4 Help Please.
Old
doro125425
Guest
 
Status:
Posts: n/a
Default Chapter 8 Exercise 4 Help Please. - 11-04-2010, 03:51 PM

Add a new function to the robot object in the MathRobot world that was presented in this chapter. The function should be named sumNumbers. It should have a Number parameter and return the sum of all the numbers from 1 up to the value passed as an argument. For example if 50 is passed as an argument, the function should return the sum of 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20 +21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+3 7+38+39+40+41+42+43+44+45+46+47+48+49. Use recursion to calculate the sum. Modify the world.animation method so it demonstrates the function.

FILE I HAVE BEEN WORKING ON IS INCLUDED.
PLEASE CAN YOU GIVE ME CODE OR UPLOAD IT BACK ONLINE?
THANKS

Alexa <3
Attached Files
File Type: a2w Chapter 8 Exercise 4.a2w (423.9 KB, 110 views)
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.