1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Trig class to perform trig function for our Graphing Calculator
  3. * (sin, cos, tan, inverses, degree to radian)
  4. * Lauren Green
  5. * 10/19/18
  6. */
  7. public class Trig
  8. {
  9. double input = 0.0;
  10. double answer;
  11. String operation = "";
  12. public void trigFunctions()
  13. {
  14. Console.println("Trigonometry Calculator Options"
  15. + "\n1: sin"
  16. + "\n2: cosin"
  17. + "\n3: tan"
  18. + "\n4: arcsin"
  19. + "\n5: arccosin"
  20. + "\n6: arctan"
  21. + "\n7: log"
  22. + "\n8: Cancel - returns to Main Menu");
  23. }
  24. //Sin method
  25. public double calcSin(double x) {
  26. answer = Math.sin(x);
  27. return answer;
  28. }
  29. //Cos method
  30. public double calcCos(double x) {
  31. answer = Math.cos(x);
  32. return answer;
  33. }
  34. //Tan method
  35. public double calcTan(double x) {
  36. answer = Math.tan(x);
  37. return answer;
  38. }
  39. //Arcsin method
  40. public double calcArcsin(double x) {
  41. answer = Math.asin(x);
  42. return answer;
  43. }
  44. //Arccos method
  45. public double calcArccos(double x) {
  46. answer = Math.acos(x);
  47. return answer;
  48. }
  49. //Arctan method
  50. public double calcArctan(double x) {
  51. answer = Math.atan(x);
  52. return answer;
  53. }
  54. //Log Method
  55. public double calcLog(double x) {
  56. answer = Math.log10(x);
  57. return answer;
  58. }
  59. //Converting from Radians to Degrees
  60. public double toDegrees(double answer)
  61. {
  62. double conversion = Math.toDegrees(answer);
  63. answer = conversion;
  64. return answer;
  65. }
  66. }