Description
The CalcGen Generator calculates the result of an equation using up to five variables. Variables can either be constant values or references to other Attributes.
The equations can contain one or multiple operations, such as addition, subtraction, multiplication, and division. Here are some calculation examples: loan interest, compound interest, bonuses based on percentages, and overtime pay.
Example Equations:
- var1 + var2
- (var2 / 15) - var3 + 3 * (var1)
- (var4 * var3) / var5 - var2 + var1
Example Variables:
- 3
- #{test.value1}
In This Article
- Video Training
- Generator Parameters
- Special Note - Generating Output as Double Value or Float Value
- Example 1 - Calculate Compound Interest
- Example 2 - Calculate Loan Interest
- Example 3 - Calculate Regular, Overtime, and Total Pay Using an Equation
Video Training
See a quick tutorial on how to use the CalcGen Generator:
Generator Parameters
The following parameters may be configured for the CalcGen Generator. Items with an asterisk* are required.
- equation* - The math equation to be evaluated.
- numberFormat* - Defines how the generated number will be formatted. Examples: 0, 0.00. #.00, #,##.00, $#,##0.00.
- var1 - The first of five possible variables to use in the equation.
- var2 - The second of five possible variables to use in the equation.
- var3 - The third of five possible variables to use in the equation.
- var4 - The fourth of five possible variables to use in the equation.
- var5 - The fifth of five possible variables to use in the equation.
Special Note - Generating Output as Double Value or Float Value
The user must include d in the equation parameter after any/both of the var values for Double Value. An f should be used for float values. This is to specify the value of the var value is either a Double or Float Value.
- f - up to 7 digits
- d - up to 15 digits
Note: For 'd', the number format is ###0.00000000000000. The number of zeros after the decimal can be reduced if desired.
Example 1 - "f" Not Added to Var Values in Equation
equation = (var1 / var2) * 2
numberFormat = ####.000
var1 = 250
var2 = 60
Output is not in FLOAT Format. The correct value should be 8.3333, not 8.0000.
Example 2 - "f" Added to Var2 in Equation
equation = (var1 / var2f) * 2
numberFormat = ####.000
var1 = 250
var2 = 60
Output is now in FLOAT format and shows the correct value:
Example 1 - Calculate Compound Interest
This example shows how to link generators to generate compound interest. You can use constant values or reference another Generator/Attribute. This example uses three linked Generators:
RangeGen - Principal
Generates an increasing number starting at 1,000 and ending at 10,000. The number will increase by 100 for each iteration and represents the principal in the formula.
RangeGen - Years
Generates an increasing number starting at 1 and ending at 10. The number increases by 1 each iteration and represents the year in the formula.
CalcGen - Compound Interest
The formula for compound interest is:
Amount = Principal (1 + rate/times compounded) ^ (times compounded * years)
These parameters have been configured:
- equation = var1*(1+var2/var3)^(var3*var4)
- numberFormat = two decimal points (####.00)
- var1 = references linked generator for the principal amount
- var2 = rate of 0.06
- var3 = compounds once annually
- var4 - references linked generator for years
Sample Output
Example 2 - Calculate Simple Interest
In this example, linked generators will calculate simple interest for a principal amount over a set term (length in years) and interest rate. This example uses the following formula:
Amount = Principal * Interest Rate * Term
Two RangeGens will be used to generate the Principal and the Term. The Interest Rate will be a constant rate of 5% (0.05).
RangeGen - Principal
Numbers will start generating at 100 and increase by 25 for each iteration.
RangeGen - Term
All default values are used for this generator and will generate sequential values starting at 1.
CalcGen - Calculate Interest
The formula for this equation is: var1 * var2 * var3
These additional parameter values have been changed:
- numberFormat = ####.00
- var1 - references principal RangeGen generator
- var2 - constant interest rate of 5% (0.05)
- var3 - references term RangeGen generator
Sample Output
The interest column would be the generated output in this example:
Example 3 - Calculate Regular, Overtime, and Total Pay Using an Equation
For this example, five Attributes have been added to calculate the regular pay, overtime pay, and total pay for individuals.
- fullName - Generates the full name of a person.
- hours - Generates work hours ranging from 1 to 80.
- regularPay - Generates regular pay based on the number of hours worked.
- overtimePay - Generates overtime pay based o the number of hours worked.
- totalPay - Adds the values generated for regular pay and overtime pay.
hours Attribute - Generator Configuration
The RandomGen Generator has been configured for the hours Attribute to generate the number of work hours between 1 and 80.
regularPay Attribute - Generator Configuration
The RegularPayGen Generator configures the regular pay based on the hours worked. For this configuration, the hours Attribute is referenced by the hoursWorked Parameter.
overTime Pay Attribute - Generator Configuration
The OvertimePayGen Generator configures the overtime pay based on the number of hours worked over the standard 40-hour work week. For this configuration, the hours Attribute is referenced by the hoursWorked Parameter.
totalPay Attribute - Generator Configuration
The CalcGen Generator adds the regular pay and overtime pay values together to determine the person's total pay based on hours worked.
For this configuration, the following has been configured:
- equation = var1+var2
- numberFormat = 0.00
- var1 = References regularPay Attribute
- var2 = References overtimePay Attrtibute