BonusFeatures.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //import java.math.Double;
  2. import java.math.*;
  3. /**
  4. * This class handles factorials and Logarithmic functions
  5. */
  6. public class BonusFeatures
  7. {
  8. // instance variables - replace the example below with your own
  9. Console console = new Console();
  10. /**
  11. * Constructor for objects of class BonusFeatures
  12. */
  13. public BonusFeatures(Console c)
  14. {
  15. console = c;
  16. }
  17. public Double factorialOf(Double value){
  18. Double f = 1.00;
  19. value = Math.floor(value);
  20. for(double i = 1; i <= value; i++)
  21. f *= i;
  22. return console.currentValue = f;
  23. }
  24. public double logarithm(Double value){
  25. return console.changeCurrentValue((double)Math.log10(value));
  26. }
  27. public Double invLogarithm(Double value){
  28. return console.changeCurrentValue(Math.pow(10.00,value));
  29. }
  30. public double lnLogarithm(Double value){
  31. return console.changeCurrentValue((double)Math.log(value));
  32. }
  33. public double expLogarithm(Double value){
  34. return console.changeCurrentValue((double)Math.exp(value));
  35. }
  36. }