第三次上机练习+作业

任务一教材P39实验3

 

listenEnglish.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>listenEnglish</title>
</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>

 

audio.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>audio</title>
</head>
<body bgcolor=pink>
<embed src="English/english.mp3"autostart=false>
课文音频
</embed>
</body>
</html>

 

 

任务二、教材P45  8

 

main.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>main</title>
</head>
<body bgcolor=cyan>
<jsp:include page="circle.jsp">
<jsp:param value="3" name="r"/>
</jsp:include>
<jsp:include page="ladder.jsp">
<jsp:param value="3" name="a"/>
<jsp:param value="5" name="b"/>
<jsp:param value="2" name="h"/>
</jsp:include>
</body>
</html>

 

circle.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>circle</title>
</head>
<body>
<%
String r=request.getParameter("r");
double R=Double.parseDouble(r);
double S=3.14*R*R;
out.print("圆的面积为"+S);
%>
</body>
</html>
ladder.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ladder</title>
</head>
<body>
<% 
 String a =request.getParameter("a");
String b =request.getParameter("b");
String h =request.getParameter("h");
double A =Double.parseDouble(a);
double B =Double.parseDouble(b);
double H =Double.parseDouble(h);
double s=(A+B)*H/2;
out.print("梯形面积为"+s);
%>
</body>

 

 

提示:圆形面积需要一个param  梯形面积需要3param,可以参考教材例2-11

任务三、

 

 

top.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="top.jsp" %>
left.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="left.jsp" %>

right.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="right.jsp" %>
end.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%="end.jsp" %>
all.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
</head>
<body>
<table border="1" bordercolor="yellow">            
        <tr>  
            <th colspan="2"><%@ include file="top.jsp" %></th>    
        </tr>
        <tr>  
            <th ><%@ include file="left.jsp" %></th>            
            <th ><%@ include file="right.jsp" %></th>    
        </tr>
        <tr>  
            <th colspan="2"><%@ include file="end.jsp" %></th>    
        </tr>
        
    </table>
</body>
</html>

 

任务四、

 

 

work4.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>work4</title>
</head>
<body>
<% double i=(int)(Math.random()*10)+1;
        if(i%2==0){   
        %>  
        <jsp:forward page="work4_1.jsp">
        <jsp:param name="number" value="<%=i %>"/>
        </jsp:forward>         
        <% }
        else{%>
 <jsp:forward page="work4_2.jsp">
       <jsp:param name="number" value="<%=i %>"/>
        </jsp:forward>
        
        <% }
        %>
</body>
</html>
work4_1.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>work4_1</title>
</head>
<body bgcolor=cyan>
<p style ="font-family:宋体;font-size:36">
<% String s=request.getParameter("number"); 
out.println("hello,我是一个偶数!"+s);
%>
</p>
</body>
</html>
work4_2.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>work4_1</title>
</head>
<body bgcolor=cyan>
<p style ="font-family:宋体;font-size:36">
<% String s=request.getParameter("number"); 
out.println("hello,我是一奇数!"+s);
%>
</p>
</body>
</html>

 

 


 

posted @ 2022-03-30 18:37  好多鱼好多鱼好剩余  阅读(23)  评论(0编辑  收藏  举报