Sine Table in JSP

There are variety of ways to define sine, cosine, etc other than the trignometric definition.

Sine Table in JSP

Sine Table in JSP

        

What is sine: There are variety of ways to define sine, cosine, etc other than the trignometric definition. They are not angles, by the way, they are the functions of angles. Many centuries ago, far too many to be certain exactly how it happened, people noticed that as long as the angles of triangles were the same, while the sides could be as long or short as you wanted, the ratios stayed the same. 

Before we proceed, its important to understand what these programs were designed to do. The main purpose of building a sine table is to create a reference table of sine values plus a fast and simple way for later program parts to retrieve sine and cosine values. Mathematically, the sine of an angle is the ratio of the length of the opposite side to the length of the hypotenuse of an imaginary right triangle having that angle in it.

To calculate the the sine we have one  function provided to calculate a sine of a function.

Here is the code of the JSP file:

<%@page import="java.util.*, java.lang.*" %> 
<html>
<head><title>Sin Table</title></head>
<body>
<h1 align="center">Sin Table</h>
<table border="1" align="center">
<%!int angles[] ={0, 30, 45, 75,90};%>
<th>Angle</th><th>Sign of Angle</th>
<% for (int i=0; i<5; i++){ %>
<tr><td><%= angles[i]%></td>
<td><%=Math.sin( Math.toRadians(angles[i]))%>
</tr>
<%} %>
</table>
</body>
<html>

Output of the Program:

Download this example.