第五周作业
1.任务一、教材P39实验3
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> </head> <body bgcolor=pink> <embed src="English/english.mp3"autostart=false> 课文音频 </embed> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body bgcolor=cyan> <br>英文课文(English Text):</br> <p style="font-famliy:宋体;font-size:18;color:black"> <jsp:include page="English/english.txt"></jsp:include> <br>课文音频(English Audio):</br> <jsp:include page="audio.jsp"></jsp:include> </body> </html>
2.任务二、教材P45 8题
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <%! public double getArea(int r){ return r*3.14; } %> <% int r = Integer.parseInt(request.getParameter("radius")); %> <br> <b>圆的半径为:<%= r %></b> <br> <b> 面积为:<%= getArea(r) %> </b> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <%! public double getArea(int u,int l,int h){ return (u+l)*h/2; } %> <% int u = Integer.parseInt(request.getParameter("up")); int l = Integer.parseInt(request.getParameter("low")); int h = Integer.parseInt(request.getParameter("height")); %> <br> <b>梯形的上底为:<%= u %>,下底为:<%= l %>,高为:<%= h %></b> <br> <b> 面积为:<%= getArea(u,l,h) %> </b> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% int r = 2,s = 2,x = 3,h = 2; %> <jsp:include page="circle.jsp"> <jsp:param value="<%= r %>" name="radius"/> </jsp:include> <jsp:include page="ladder.jsp"> <jsp:param value="<%= s %>" name="up"/> <jsp:param value="<%= x %>" name="low"/> <jsp:param value="<%= h %>" name="height"/> </jsp:include> </body> </html>
3.任务三、详见Word图片
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>M</title> <style type="text/css"> .box{ width: 460px; height: 90px; display:flex; justify-content:center; align-items:center; } .top{ width: 460px; height: 30px; line-height: 30px; background: green; text-align: center; } .left{ width: 230px; height: 30px; line-height: 30px; background: red; text-align: center; float:left; } .main{ width: 230px; height: 30px; line-height: 30px; background: blue; text-align: center; float:right; } .end{ width: 460px; height: 30px; line-height: 30px; background: yellow; text-align: center; } </style> </head> <body> <div class="box"> <div class="top"> <jsp:include page="3.top.jsp"></jsp:include> </div> <div class="left"> <jsp:include page="3.left.jsp"></jsp:include> </div> <div class="main"> <jsp:include page="3.main.jsp"></jsp:include> </div> <div class="end"> <jsp:include page="3.end.jsp"></jsp:include> </div> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
top.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
left.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
main.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
end.jsp文件
4.任务四、详见Word
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% int i = Math.round((int) (Math.random() * 10)); if (i % 2 == 0) { %> <jsp:forward page="even.jsp"></jsp:forward> <% } else { %> <jsp:forward page="odd.jsp"></jsp:forward> <% } %> </body> </html>
<%@ 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>My JSP 'one.jsp' starting page</title> </head> <body> <% String m = request.getParameter("num"); int n = Integer.parseInt(m); out.print("随机数为" + n + "<br>"); %> Hello,我是一个奇数! </body> </html>
<%@ 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>My JSP 'two.jsp' starting page</title> </head> <body> <% String m = request.getParameter("num"); int n = Integer.parseInt(m); out.print("随机数为" + n + "<br>"); %> Hello,我是一个偶数! </body> </html>