simpleOp.java 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Write a description of class simpleOp here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. import java.util.*;
  8. public class simpleOp
  9. {
  10. public static double currentNumber = 0;
  11. public static double add(double x, double y){
  12. //CALULATES THE SUM OF TWO NUMBERS
  13. currentNumber = x + y;
  14. //System.out.println(currentNumber);
  15. return currentNumber;
  16. }
  17. public static double sub(double x, double y){
  18. //CALULATES THE DIFFERENCE OF TWO NUMBERS
  19. currentNumber = x - y;
  20. //System.out.println(currentNumber);
  21. return currentNumber;
  22. }
  23. public static double mul(double x, double y){
  24. //CALULATES THE PRODUCT OF TWO NUMBERS
  25. currentNumber = x * y;
  26. //System.out.println(currentNumber);
  27. return currentNumber;
  28. }
  29. public static double div(double x, double y){
  30. //CALULATES THE QUOTIENT OF TWO NUMBERS
  31. currentNumber = x / y;
  32. //System.out.println(currentNumber);
  33. return currentNumber;
  34. }
  35. public static double squ(double x){
  36. //CALULATES THE SQUARE OF ONE NUMBER
  37. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  38. currentNumber = (int) Math.pow(x,2);
  39. //System.out.println(currentNumber);
  40. return currentNumber;
  41. }
  42. public static double sqrt(double x){
  43. //CALULATES THE SQUARE ROOT OF ONE NUMBER
  44. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  45. currentNumber = (int) Math.sqrt(x);
  46. //System.out.println(currentNumber);
  47. return currentNumber;
  48. }
  49. public static double exp(double x, double y){
  50. //CALULATES EXPONENTIATION OF X TO POWER OF Y
  51. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  52. currentNumber = (int) Math.pow(x,y);
  53. //System.out.println(currentNumber);
  54. return currentNumber;
  55. }
  56. public static double inv(double x){
  57. //CALULATES THE INVERSE OF NUMBER
  58. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  59. currentNumber = (1/x);
  60. //System.out.println(currentNumber);
  61. return currentNumber;
  62. }
  63. public static double invert(double x){
  64. //TURNS NEGATIVE TO POSITIVE OR POSITIVE TO NEGATIVE
  65. currentNumber = -x;
  66. //System.out.println(currentNumber);
  67. return currentNumber;
  68. }
  69. }