simpleOp.java 2.2KB

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