FileDocCategorySizeDatePackage
FinalParameters.javaAPI DocExample2056Sun Dec 14 22:47:40 GMT 2003oreilly.hcj.finalstory

FinalParameters

public class FinalParameters extends Object
Demonstration of final constants.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.3 $

Fields Summary
private static final double
M
Contains a constant for both equations.
Constructors Summary
Methods Summary
public doubleequation2(double inputValue)
Calculate the results of an equation.

param
inputValue Input to the equation.
return
result of the equation.


	                  	 
	    
		final double K = 1.414;
		final double X = 45.0;

		double result = (((Math.pow(inputValue, 3.0d) * K) + X) * M);

		double powInputValue = 0;
		if (result > 360) {
			powInputValue = X * Math.sin(result);
		} else {
			inputValue = K * Math.sin(result);
		}

		result = Math.pow(result, powInputValue);
		if (result > 360) {
			result = result / inputValue;
		}

		return result;
	
public doubleequation2Better(double inputValue)
Calculate the results of an equation.

param
inputValue Input to the equation.
return
result of the equation.

		final double K = 1.414;
		final double X = 45.0;

		double result = (((Math.pow(inputValue, 3.0d) * K) + X) * M);

		double powInputValue = 0;
		if (result > 360) {
			powInputValue = X * Math.sin(result);
		} else {
			// inputValue = K * Math.sin(result); // <= Compiler error
		}

		result = Math.pow(result, powInputValue);
		if (result > 360) {
			result = result / inputValue;
		}

		return result;