Jsp课后习题2.7

题目:

用jsp求出梯形的面积,要用到#include导入文件。 主文件main.jsp,被导入文件lader.jsp

 

备注:同样的功能也可以用Html5+js来实现

固定数值实现:

main.jsp

<%@ page contentType = "text/html;charset=utf-8" %>







    

    

    






lader.jsp

<%@ page contentType = "text/html; charset=UTF-8" %>





<%
    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;

%>

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

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

梯形高为:<%=h %>

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

 

你可能感兴趣的:(web开发)