MY CODE >> Average Calculator with Listener
// The point of this code is to listen for a user to say one or more numbers and return the 
// average of the numbers.  All of the numbers are stored in a list.  The code also gives the 
// user 3 commands: List, Clear and Average.  If the user says the word List then a list of 
// the numbers all stored will be displayed.  If the user says Clear then the list will be 
// emptied.  If the user says Average then an average of the numbers stored will be returned.

list ave;
float num;

default
{
    state_entry()
    {
        llListen(0, "", NULL_KEY, "");
        llSetText(
        
            "This object will tell you the average of a set of numbers. \n 
            Please say numbers individually. \n
            For a list of the numbers already entered say List. \n
            To clear the list say Clear. \n
            When ready say Average. \n"
        
        ,<1,1,1>, 2.0);
        
    }
    
    listen(integer channel, string name, key id, string message) {
        
        if (message == "0") {
            num = (float)message;
            ave += num;
            llOwnerSay("Number Received");
        }
        else {
            num = (float)message;
            if (num == 0) {
                // Nothing happens here intentionally
            }
            else {
                ave += num;
                llOwnerSay("Number Received");
            }
        }
                
        if (llToUpper(message) == "LIST") {
            llOwnerSay("<" + llDumpList2String(ave,"><") + ">");
        }
        
        
        else if (llToUpper(message) == "AVERAGE") {
            if (llGetListLength(ave) == 0) {
                llOwnerSay("Please enter a numeber");
            }
            else {
                llSay(0,"The average of the list is " +
                    (string)llListStatistics (LIST_STAT_MEAN, ave));
            }
        }
        
        else if (llToUpper(message) == "CLEAR") {
            ave = [];
            llOwnerSay("Clearing");
        }
        
    }
}