1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: Cancel - returns to Main Menu");
  22. }
  23. //Sin method
  24. public double calcSin(double x) {
  25. answer = Math.sin(x);
  26. return answer;
  27. }
  28. //Cos method
  29. public double calcCos(double x) {
  30. answer = Math.cos(x);
  31. return answer;
  32. }
  33. //Tan method
  34. public double calcTan(double x) {
  35. answer = Math.tan(x);
  36. return answer;
  37. }
  38. //Arcsin method
  39. public double calcArcsin(double x) {
  40. answer = Math.asin(x);
  41. return answer;
  42. }
  43. //Arccos method
  44. public double calcArccos(double x) {
  45. answer = Math.acos(x);
  46. return answer;
  47. }
  48. //Arctan method
  49. public double calcArctan(double x) {
  50. answer = Math.atan(x);
  51. return answer;
  52. }
  53. //Converting from Radians to Degrees
  54. public double toDegrees(double answer)
  55. {
  56. double conversion = Math.toDegrees(answer);
  57. answer = conversion;
  58. return answer;
  59. }
  60. }