scienticFunctions.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Write a description of class scienticFunctions here.
  3. *
  4. * @author (Roy Mpanju)
  5. * @version (a version number or a date)
  6. */
  7. import java.lang.*;
  8. public class scienticFunctions
  9. {
  10. // instance variables - replace the example below with your own
  11. //private int x;
  12. /**
  13. * Constructor for objects of class scienticFunctions
  14. */
  15. // public scienticFunctions()
  16. // {
  17. // // initialise instance variables
  18. // x = 0;
  19. // }
  20. /**
  21. * A method - find the cosine of a given number
  22. *
  23. * @param y a sample parameter for a method
  24. * @return the cosine of y
  25. */
  26. public double cosine(double y)
  27. {
  28. double x = Math.toRadians(y);
  29. return Math.cos(x);
  30. }
  31. /**
  32. * A method - find the sine of a given number by converting it to radians
  33. *
  34. * @param y a sample parameter for a method
  35. * @return the sine of y
  36. */
  37. public static double sine(double y){
  38. return Math.sin(Math.toRadians(y));
  39. }
  40. public static double cos(double y){
  41. return Math.cos(Math.toRadians(y));
  42. }
  43. public double tangent(double y){
  44. return Math.tan(Math.toRadians(y));
  45. }
  46. public double inverseCosine(double y){
  47. return Math.acos(y) * 180/Math.PI;
  48. }
  49. public double inverseSine(double y){
  50. return (Math.asin(y))* 180/Math.PI;
  51. }
  52. public double inverseTangent(double y){
  53. return (Math.atan(y))*180/Math.PI;
  54. }
  55. }