其他分享
首页 > 其他分享> > 第三次

第三次

作者:互联网

任务一、教材P39实验3

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  </head>
  
  <body bgcolor=blue>
    <embed src="english/english.mp3" autostart = false>
    课文音频
    </embed>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
  </head>
   <body bgcolor = cyan>
     <br>英文课文(English Text):</br>
     <p style="font-family:宋体;font-size:18;color:black">
     <jsp:include page="english/english.txt"/>
     <br>课文音频(English Audio):</br>
     <jsp:include page="audio.jsp"/>
     </p>
  </body>
</html>

 

 任务二、教材P45  8题

<body>
 <%
    double r=3,a=2,b=5,c=2;
 %>
    <jsp:include page="circle.jsp">
         <jsp:param value="<%=r %>" name="sideR"/>
     </jsp:include>
   <p>-----------------------------</p>
    <jsp:include page="ladder.jsp">
         <jsp:param value="<%=a %>" name="sideA"/>
         <jsp:param value="<%=b %>" name="sideB"/>
         <jsp:param value="<%=c %>" name="sideC"/>
     </jsp:include>
 </body>
<body>
 <%
    String sideR=request.getParameter("sideR");
    double r=Double.parseDouble(sideR);
%>
   <%!    public String getArea(double r)
    {
        if(r>0)
        {
            double area=r*r*3.14;
            return ""+area;
        }
        else{
            return("半径小于0,不能计算");
        }
    }
%>
 
           半径是:<%=r%>
<br>圆的面积是:<%=getArea(r) %>
 </body>
<body>
   <%
     String sideA=request.getParameter("sideA");
     String sideB=request.getParameter("sideB");
     String sideC=request.getParameter("sideC");
     double a=Double.parseDouble(sideA);
     double b=Double.parseDouble(sideB);
     double c=Double.parseDouble(sideC);
 %>
    <%!    public String getArea(double a,double b,double c)
     {
         if(a>0&&b>0&&c>0)
         {
             double area=(a+b)*c/2;
             return ""+area;
         }
         else{
             return("长宽高输入错误");
         }
     }
 %>
  
上底:<%=sideA%> 下底:<%=sideB %>高是:<%=sideC %>
 <br>梯形的面积是:<%=getArea(a,b,c) %>
  </body>

任务三

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>starting page</title>
  </head>
  <body >
  <table border="1" width="600" align="center" bgcolor="pink">
  <tr align="center"><td colspan="2"bgcolor="orange"><%@include file="above.jsp" %></td></tr>
  <tr align="center"><td bgcolor="pink"><%@include file="left.jsp" %></td><td align="center"bgcolor="red"><%@include file="right.jsp" %></td></tr>
  <tr align="center"><td colspan="2"><%@include file="underneath.jsp" %></td></tr>
  </table>
    
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="top.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="left.jsp"%>
 
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="underneath.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="right.jsp"%>

 

 

任务四、

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  
  <body>
     <% 
   String s=request.getParameter("number");
   int a=Integer.parseInt(s);
   out.println("随机数是"+a);
    %>
    <h1>Hello,我是一个偶数!</h1>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
      <% 
   String s=request.getParameter("number");
   int a=Integer.parseInt(s);
   out.println("随机数是"+a);
    %>
    <h1>Hello,我是一个奇数!</h1>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>index</title>
  </head>
  
  <body>
    <h1>产生一个0到10的随机整数</h1>
    <%
    int i= (int)Math.round(Math.random()*10);
    if(i%2==0){
     %>
     <jsp:forward page="even.jsp">
     <jsp:param value="<%=i %>" name="number"/>
     </jsp:forward>
     <%
     }else{
      %>
      <jsp:forward page="oddNumber.jsp">
      <jsp:param value="<%=i %>" name="number"/>
      </jsp:forward>
      <%
      }
       %>
  </body>
</html>

 

 

 

 

搜索

复制

标签:return,第三次,area,number,name,else,课文
来源: https://www.cnblogs.com/leopard1/p/16091488.html