Alice Community Need help with calculating averages.

 Need help with calculating averages.
 raccoons Junior Member   Status: Offline Posts: 2 Join Date: Mar 2018 Location: Somewhere in Ohio 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.
sometimes618
Member

Status: Offline
Posts: 40
Join Date: Jan 2016
Location: J Street
04-16-2018, 05:27 PM

Quote:
 Originally Posted by raccoons 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:

raccoons
Junior Member

Status: Offline
Posts: 2
Join Date: Mar 2018
Location: Somewhere in Ohio
04-17-2018, 08:24 AM

Quote:
 Originally Posted by sometimes618 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.

 sometimes618 Member   Status: Offline Posts: 40 Join Date: Jan 2016 Location: J Street 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
chickentree
Super Moderator

Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
04-19-2018, 04:23 PM

Quote:
 Originally Posted by raccoons 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

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge