MathMethods.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import java.util.*;
  2. /**
  3. * Write a description of class Calculator here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class MathMethods
  9. {
  10. public static Double add(double n1, double n2){
  11. return (n1 + n2);
  12. }
  13. public static Double subtract(double n1, double n2){
  14. return (n1 - n2);
  15. }
  16. public static Double multiply(double n1, double n2){
  17. return (n1 * n2);
  18. }
  19. public static Double divide(double n1, double n2){
  20. return (n1 / n2);
  21. }
  22. public static Double exponent(double n1, double n2){
  23. return (Math.pow(n1, n2));
  24. }
  25. public static Double cosine(double n1){
  26. return (Math.cos(n1));
  27. }
  28. public static Double invCosine(double n1){
  29. return (Math.acos(n1));
  30. }
  31. public static double squareRoot(double n1) {
  32. return (Math.sqrt(n1));
  33. }
  34. public static double invert(double n1) {
  35. return (n1*-1);
  36. }
  37. public static double sin(double n1){
  38. return (Math.sin(n1));
  39. }
  40. public static double iSin(double n1){
  41. return (Math.asin(n1));
  42. }
  43. public static double degToRad(double n1) {
  44. return (Math.toRadians(n1));
  45. }
  46. public static double radToDeg(double n1) {
  47. return (Math.toDegrees(n1));
  48. }
  49. public static double square(double n1) {
  50. return Math.pow(n1, 2);
  51. }
  52. public static double inverse(double n1) {
  53. return n1;
  54. }
  55. public static double tangent(double n1) {
  56. return Math.tan(n1);
  57. }
  58. public static double itan(double n1) {
  59. return Math.atan(n1);
  60. }
  61. public static void printAns(String printAnswer){
  62. System.out.println("ANSWER: " + printAnswer);
  63. }
  64. }
  65. // public static double squareRoot(double n1) {
  66. // double result = Math.sqrt(x);
  67. // return result;
  68. // }
  69. // public static double invert(double n1) {
  70. // double result = x*-1;
  71. // return result;
  72. // }
  73. // public static double sin(double n1){
  74. // double result = Math.sin(x);
  75. // return result;
  76. // }
  77. // public static double iSin(double n1){
  78. // double result = Math.asin(x);
  79. // return result;
  80. // }
  81. // public static double degToRad(double n1) {
  82. // double result = Math.toRadians(x);
  83. // return result;
  84. // }
  85. // public static double radToDeg(double n1) {
  86. // double result = Math.toDegrees(x);
  87. // return result;
  88. // }
  89. // public static Double exponent(double n1, double n2){
  90. // return (Math.pow(n1, n2));
  91. // }
  92. // public static Double cosine(double n1){
  93. // return (Math.cos(n1));
  94. // }
  95. // public static Double invCosine(double n1){
  96. // return (Math.acos(n1));
  97. // }