1 package edu.psu.geovista.app.spreadsheet.functions;
2
3 import edu.psu.geovista.app.spreadsheet.table.SSTableModel;
4 import edu.psu.geovista.app.spreadsheet.formula.Node;
5 import edu.psu.geovista.app.spreadsheet.formula.Formula;
6 import edu.psu.geovista.app.spreadsheet.exception.ParserException;
7 import edu.psu.geovista.app.spreadsheet.exception.NoReferenceException;
8
9 /*
10 * Description:
11 * <code>AVERAGE</code><br>
12 * usage: <code>=AVERAGE(parameter list)</code><br>
13 * returns the arithmetic mean of the specified parameters<br>
14 * example: <code>=AVERAGE(1,2,3)</code> returns <code>2.0</code>
15 * Date: Mar 25, 2003
16 * Time: 10:43:56 AM
17 * @author Jin Chen
18 */
19
20 public class FunctionAverage extends Function {
21
22 public Number evaluate( Node node) throws ParserException,NoReferenceException {
23 //Function sumf=Formula.getFuncHandler("SUM");
24 Function sumf=this.getSupportFuntion("SUM",this.getOwner() );
25 float sum=sumf.evaluate(node).floatValue() ;
26 //Function fcf=Formula.getFuncHandler("FUN_COUNT");
27 Function fcf=this.getSupportFuntion("FUN_COUNT",this.getOwner());
28 int nCells=fcf.evaluate(node).intValue() ;
29 return new Float(sum/nCells);
30 }
31
32 public String getUsage() {
33 return "AVERAGE(value1,value2,...)";
34 }
35
36 public String getDescription() {
37 return "Returns the average (arithmetric mean) of its arguments.";
38 }
39 }
40
This page was automatically generated by Maven