ScientificFunctions.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. public class ScientificFunctions
  2. {
  3. public static double display = 0;
  4. public static double memory = 0;
  5. public static boolean degMode = true;
  6. public static boolean radMode = false;
  7. public static boolean decMode = true;
  8. public static boolean hexMode = false;
  9. public static boolean binMode = false;
  10. public static boolean octMode = false;
  11. public static boolean celsius;
  12. public static boolean fahrenheit;
  13. public static String hexOut;
  14. public static String binOut;
  15. public static String octOut;
  16. public static double sqr(double display) {
  17. System.out.println( display * display);
  18. return display = display * display;
  19. }
  20. public static double sqRoot(double display) {
  21. System.out.println(Math.sqrt(display));
  22. return display = Math.sqrt(display);
  23. }
  24. public static double invFraction(double display) {
  25. System.out.println( 1 / display);
  26. return display = 1 / display;
  27. }
  28. public static double invSign(double display) {
  29. System.out.println( -1*display);
  30. return display = -1*display;
  31. }
  32. public static double setMem(double display) {
  33. System.out.println("Set to memory!");
  34. return memory = display;
  35. }
  36. public static double resetMem() {
  37. System.out.println("Memory Reset!");
  38. return memory = 0;
  39. }
  40. public static double recallMem() {
  41. System.out.println("Memory Recalled!");
  42. return display = memory;
  43. }
  44. public static double cosine(double display) {
  45. if (degMode == true){
  46. System.out.println(Math.cos(Math.toRadians(display)));
  47. return Math.cos(Math.toRadians(display));
  48. } else {
  49. System.out.println(Math.cos(display));
  50. return Math.cos(display);
  51. }
  52. }
  53. public static double sin(double display) {
  54. if (degMode == true){
  55. System.out.println(Math.sin(Math.toRadians(display)));
  56. return Math.sin(Math.toRadians(display));
  57. } else {
  58. System.out.println(Math.sin(display));
  59. return Math.sin(display);
  60. }
  61. }
  62. public static double tan(double display) {
  63. if (degMode == true){
  64. System.out.println(Math.tan(Math.toRadians(display)));
  65. return Math.tan(Math.toRadians(display));
  66. } else {
  67. System.out.println(Math.tan(display));
  68. return Math.tan(display);
  69. }
  70. }
  71. public static double acosin(double display) {
  72. if (degMode == true){
  73. System.out.println(Math.acos(Math.toRadians(display)));
  74. return Math.acos(Math.toRadians(display));
  75. } else {
  76. System.out.println(Math.acos(display));
  77. return Math.acos(display);
  78. }
  79. }
  80. public static double asin(double display) {
  81. if (degMode == true){
  82. System.out.println(Math.asin(Math.toRadians(display)));
  83. return Math.asin(Math.toRadians(display));
  84. } else {
  85. System.out.println(Math.asin(display));
  86. return Math.asin(display);
  87. }
  88. }
  89. public static double atan(double display) {
  90. if (degMode == true){
  91. System.out.println(Math.atan(Math.toRadians(display)));
  92. return Math.atan(Math.toRadians(display));
  93. } else {
  94. System.out.println(Math.atan(display));
  95. return Math.atan(display);
  96. }
  97. }
  98. public static double cToF(double display){
  99. System.out.println((5 * (display - 32 ) / 9));
  100. return (5*(display-32)/9);
  101. }
  102. public static double fToC(double display){
  103. System.out.println(9*(display/5)+32);
  104. return (9*(display/5)+32);
  105. }
  106. }