double: Finding Average Grades : Data Type « JSP « Java






double: Finding Average Grades

<HTML>
  <HEAD>
    <TITLE>Finding Average Grades</TITLE>
  </HEAD>

  <BODY>
    <H1>Finding Average Grades</H1>
    <%
        double grades[] = {88, 98, 73, 56, 86, 64};
        double sum, average;

        sum = 0;

        for (int i = 0; i < grades.length; i++) {
            sum += grades[i];
        }

        average = sum / grades.length;

        out.println("Average grade = " + average);
    %>
  </BODY>
</HTML>

           
       








Related examples in the same category

1.Casting to a New Type
2.An Automatic Data Conversion
3.Scriptlet Example