Alice Community  

Go Back   Alice Community > Alice 3 > How Do I?

Reply
 
Thread Tools Display Modes
Need help with calculating averages.
Old
raccoons
Junior Member
 
Status: Offline
Posts: 2
Join Date: Mar 2018
Location: Somewhere in Ohio
Default Need help with calculating averages. - 04-16-2018, 09:33 AM

All I can find to help guide me is old stuff from alice 2, and it isn't that helpful.
   
Reply With Quote
Old
sometimes618
Member
 
Status: Offline
Posts: 39
Join Date: Jan 2016
Location: J Street
Default 04-16-2018, 05:27 PM

Quote:
Originally Posted by raccoons View Post
All I can find to help guide me is old stuff from alice 2, and it isn't that helpful.
I'm sort of a novice when it comes to Alice 3, although for something like calculating averages, I don't imagine it would be massively different from Alice 2. You would just need a way to get multiple values, add those values together, evaluate how many values there are, and divide the sum of the values by the number of values. Lists are helpful for something like this, although I don't even know if lists exist in Alice 3.
If you're having trouble with any of these steps, say so but give plenty of information. This is a general rule of thumb if you're looking for help on the forums.


Starring, written, directed, and produced by sometimes618.

Get Alice Fighters v0.7:
http://www.alice.org/community/showthread.php?p=57651#post57651
   
Reply With Quote
Old
raccoons
Junior Member
 
Status: Offline
Posts: 2
Join Date: Mar 2018
Location: Somewhere in Ohio
Default 04-17-2018, 08:24 AM

Quote:
Originally Posted by sometimes618 View Post
I'm sort of a novice when it comes to Alice 3, although for something like calculating averages, I don't imagine it would be massively different from Alice 2. You would just need a way to get multiple values, add those values together, evaluate how many values there are, and divide the sum of the values by the number of values. Lists are helpful for something like this, although I don't even know if lists exist in Alice 3.
If you're having trouble with any of these steps, say so but give plenty of information. This is a general rule of thumb if you're looking for help on the forums.
Would showing the tutorial I'm using maybe help, so you can see what method I'm trying to apply to Alice 3?
I've found so far that things seem to be much more straightforward in Alice 2 from what I see, but I have no real experiences with it to confirm this.
So far I've been trying to use a function to calculate averages, but some of the stuff doesn't work the same way (I think, again, no real experience with Alice 2), and instead of it being simple, I'm just weaving big, messy lines of code that do absolutely nothing.

Also, yes, lists exist as far as I know, judging on screenshots I've seen and the like. Personally, I don't really know all that much of them, though. :$

Last edited by raccoons; 04-17-2018 at 08:29 AM.
   
Reply With Quote
Old
sometimes618
Member
 
Status: Offline
Posts: 39
Join Date: Jan 2016
Location: J Street
Default 04-18-2018, 05:52 AM

So...after banging stuff into Alice 3, I think I have something.
You'll need two variables, one for the number of numbers and another for the sum. At the beginning, "sum" should be 0 and "number" should be an integer that is asked from a user. For "number" times, the sum should be the previous sum added to a decimal that the user puts in. After that, divide the sum by "number" and you should get the average.
I don't know how to turn that into a string for the user to see, though, but again I'm not too good with Alice 3.


Starring, written, directed, and produced by sometimes618.

Get Alice Fighters v0.7:
http://www.alice.org/community/showthread.php?p=57651#post57651
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 04-19-2018, 04:23 PM

Quote:
Originally Posted by raccoons View Post
All I can find to help guide me is old stuff from alice 2, and it isn't that helpful.
In general you need to input entries and divide their sum by the number of entries that were given. That means you need some way to tell your method when you have entered the last value. I chose to make the last value a negative number and not to count it in the sum or count of entries.

After the last value is entered you must display the results of the sum/count. This is the only step that I needed an object for and I chose the "text mode" object, although you could use something with a "say" method.

Creating variables in Alice 3 is a little different, you click on variables in the code area and then fill out the dialog that pops up. I needed a Boolean to control the while loop but the others can all be floats.

Remember that, just as with many things in Alice 2, you need to initially use a dummy value and then, after the statement is in the method/function go back and fill in the correct value for your program.

If you need more help please provide a sample of what you have to date.

Mark


Mark Henwood
mhenwood@ieee.org
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.