simpleOp.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 NumberOne(){
  11. // String getFirst = Console.getStringInput("Please enter number.");
  12. // currentNumber = Console.getNumber(getFirst);
  13. // return currentNumber;
  14. // }
  15. public static double add(double x, double y){
  16. //CALULATES THE SUM OF TWO NUMBERS
  17. Console.currentNumber = x + y;
  18. //System.out.println(currentNumber);
  19. return Console.currentNumber;
  20. }
  21. public static double sub(double x, double y){
  22. //CALULATES THE DIFFERENCE OF TWO NUMBERS
  23. Console.currentNumber = x - y;
  24. //System.out.println(currentNumber);
  25. return Console.currentNumber;
  26. }
  27. public static double mul(double x, double y){
  28. //CALULATES THE PRODUCT OF TWO NUMBERS
  29. Console.currentNumber = x * y;
  30. //System.out.println(currentNumber);
  31. return Console.currentNumber;
  32. }
  33. public static double div(double x, double y){
  34. //CALULATES THE QUOTIENT OF TWO NUMBERS
  35. Console.currentNumber = x / y;
  36. if(y == 0){
  37. System.out.println("Err");
  38. Console.currentNumber = 0;
  39. }
  40. return Console.currentNumber;
  41. }
  42. public static double squ(double x){
  43. //CALULATES THE SQUARE OF ONE NUMBER
  44. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  45. Console.currentNumber = Math.pow(x,2);
  46. //System.out.println(currentNumber);
  47. return Console.currentNumber;
  48. }
  49. public static double sqrt(double x){
  50. //CALULATES THE SQUARE ROOT OF ONE NUMBER
  51. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  52. Console.currentNumber = Math.sqrt(x);
  53. //System.out.println(currentNumber);
  54. return Console.currentNumber;
  55. }
  56. public static double exp(double x, double y){
  57. //CALULATES EXPONENTIATION OF X TO POWER OF Y
  58. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  59. Console.currentNumber = Math.pow(x,y);
  60. //System.out.println(currentNumber);
  61. return Console.currentNumber;
  62. }
  63. public static double inv(double x){
  64. //CALULATES THE INVERSE OF NUMBER
  65. //CASTED TO double FOR NOW... IT'S IN ALPHA, YOU DIG?
  66. Console.currentNumber = (1/x);
  67. //System.out.println(currentNumber);
  68. return Console.currentNumber;
  69. }
  70. public static double invert(double x){
  71. //TURNS NEGATIVE TO POSITIVE OR POSITIVE TO NEGATIVE
  72. Console.currentNumber = -x;
  73. //System.out.println(currentNumber);
  74. return Console.currentNumber;
  75. }
  76. }