igpp.util
Class Calc

java.lang.Object
  extended by igpp.util.Calc

public class Calc
extends Object

Perform simple mathematical operations.

Since:
1.0.0
Version:
1.0.0
Author:
Todd King, UCLA/IGPP

Constructor Summary
Calc()
           
 
Method Summary
static long ceil(double v)
          Round a value up to nearest integer and return value as a long.
static long floor(double v)
          Round a value down to nearest integer and return value as a long.
static double perform(double v1, String operation, double v2)
          Perform an operation on two arguments.
static double perform(double v1, String operation, String v2)
          Perform an operation on two arguments.
static double perform(int v1, String operation, String v2)
          Perform an operation on two arguments.
static double perform(long v1, String operation, long v2)
          Perform an operation on two arguments.
static double perform(long v1, String operation, String v2)
          Perform an operation on two arguments.
static double perform(String v1, String operation, double v2)
          Perform an operation on two arguments.
static double perform(String v1, String operation, int v2)
          Perform an operation on two arguments.
static double perform(String v1, String operation, long v2)
          Perform an operation on two arguments.
static double perform(String v1, String operation, String v2)
          Perform an operation on two arguments.
static double sum(ArrayList<String> list)
          Sum all the values in a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Calc

public Calc()
Method Detail

perform

public static double perform(double v1,
                             String operation,
                             double v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(String v1,
                             String operation,
                             String v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(long v1,
                             String operation,
                             String v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(int v1,
                             String operation,
                             String v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(double v1,
                             String operation,
                             String v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(String v1,
                             String operation,
                             double v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(String v1,
                             String operation,
                             long v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(String v1,
                             String operation,
                             int v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

perform

public static double perform(long v1,
                             String operation,
                             long v2)
Perform an operation on two arguments. All match is done as double.

Parameters:
v1 - the first operand
operation - the symbol for the operation. Allowed values are: -, +, *, /, %
v2 - the second operand
Returns:
the result of performing the operation on arg1 and arg2.

floor

public static long floor(double v)
Round a value down to nearest integer and return value as a long.

Parameters:
v - the value
Returns:
the value rounded down.

ceil

public static long ceil(double v)
Round a value up to nearest integer and return value as a long.

Parameters:
v - the value
Returns:
the value rounded down.

sum

public static double sum(ArrayList<String> list)
Sum all the values in a list.

Parameters:
list - an set of value to sum
Returns:
the result of performing the operation on arg1 and arg2.


Copyright © 2008-2009 Regents University of California. All Rights Reserved.