JSP计算梯形面积

时间:2024-04-13 17:26:56

lader代码

<%@ page contentType = "text/html; charset=GB2312" %>

<HTML>


<BODY>


<%
	String topLine = request.getParameter("topLine");
	
                String baseLine = request.getParameter("baseLine");

	String height = request.getParameter("height");

	
double a = Double.parseDouble(topLine);

	
double b = Double.parseDouble(baseLine);

	
double h = Double.parseDouble(height);

	
double area = (a+b)*h/2;


%>


<p> 梯形上底为:<%=a %>
	

<br>


<p> 梯形下底为:<%=b %>


<br>


<p>梯形高为:<%=h %>


<br>
<p> 梯形面积为:
<%=area %>


</BODY>
</HTML>

main代码

<%@ page contentType = "text/html;charset=GB2312" %>
<HTML>


<BODY>
 
       
<jsp:include page="lader.jsp">

            
<jsp:param name="topLine" value="5"/>

            
<jsp:param name="baseLine" value="10"/>

            
<jsp:param name="height" value="6"/>
 
       
</jsp:include>
    

</BODY>

</HTML>

结果

JSP计算梯形面积