jsp第三次作业

陌路散爱 提交于 2020-03-24 21:27:22
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
    <div>
        <form action="main.jsp">
            <input type="number" id="cs1" name="R" placeholder="请输入圆的半径">
            <input type="submit" value="确定">
        </form>
    </div>
    <%
        String R=request.getParameter("R");
        if(R!=null){
            double cr=Double.parseDouble(R);
            double cs=cr*cr*3.14;
            out.print("输入圆的半径为:"+cr+"。得出圆的面积为"+cs);
            request.setAttribute("cr", cr);
            request.setAttribute("cs", cs);
        }
        
    %>
    
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
    <div>
        <form action="main.jsp">
            <input type="number" name="SD" placeholder="请输入梯形上底">
            <input type="number" name="XD" placeholder="请输入梯形下底">
            <input type="number" name="H" placeholder="请输入梯形的高">
            <input type="submit" value="确定">
        </form>
    </div>
    <%
        String SD=request.getParameter("SD");
        String XD=request.getParameter("XD");
        String H=request.getParameter("H");
        if(SD!=null&&XD!=null&&H!=null){
            double sd=Double.parseDouble(SD);
            double xd=Double.parseDouble(XD);
            double h=Double.parseDouble(H);
            double ls=(sd+xd)*h/2;
            out.print("输入的梯形上底、下底、高分别为:"+sd+"、"+xd+"、"+h+"。得出梯形的面积为:"+ls);
            request.setAttribute("sd", sd);
            request.setAttribute("xd", xd);
            request.setAttribute("h", h);
            request.setAttribute("ls", ls);
        }
    %>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="circle.jsp" %>
<%@ include file="ladder.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>

 

 

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!