Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. /*
  2. (Use trigonometric methods) Print the following table to display the sin value and
  3. cos value of degrees from 0 to 360 with increments of 10 degrees. Round the
  4. value to keep four digits after the decimal point.
  5. Degree Sin Cos
  6. 0 0.0000 1.0000
  7. 10 0.1736 0.9848
  8. ...
  9. 350 -0.1736 0.9848
  10. 360 0.0000 1.0000
  11. */
  12. public class Exercise520 {
  13. public static void main(String[] args) {
  14. System.out.println("\n Degree Sine Cosine");
  15. System.out.println("________________________________");
  16. int i=0;
  17. System.out.print(" "+i+" ");
  18. System.out.printf("%-6.4f ",sine(i));
  19. System.out.printf("%-6.4f\n", cosine(i));
  20. for(i=10; i<=90; i++) {
  21. System.out.print(" "+i+" ");
  22. System.out.printf("%-6.4f ",sine(i));
  23. System.out.printf("%-6.4f\n", cosine(i));
  24. i = i+9;
  25. }
  26. for(i=100; i<=180; i++) {
  27. System.out.print(" "+i+" ");
  28. System.out.printf("%-6.4f ",sine(i));
  29. System.out.printf("%-6.4f\n", cosine(i));
  30. i = i+9;
  31. }
  32. for(i=190; i<=270; i++) {
  33. System.out.print(" "+i+" ");
  34. System.out.printf("%-6.4f ",sine(i));
  35. System.out.printf("%-6.4f\n", cosine(i));
  36. i = i+9;
  37. }
  38. for(i=280; i<=360; i++) {
  39. System.out.print(" "+i+" ");
  40. System.out.printf("%-6.4f ",sine(i));
  41. System.out.printf("%-6.4f\n", cosine(i));
  42. i = i+9;
  43. }
  44. }
  45.  
  46.  
  47. public static double sine(double i) {
  48. double sinAngle = Math.sin(i/180*Math.PI);
  49. return sinAngle;
  50. }
  51.  
  52. public static double cosine(double i) {
  53. double cosAngle = Math.cos(i/180*Math.PI);
  54. return cosAngle;
  55. }
  56. }
Add Comment
Please, Sign In to add comment