上机实验
1.消费总和
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <%@ page contentType="text/html"%> 3 <%@ page import="java.util.regex.Pattern"%> 4 <%@ page import="java.util.regex.Matcher"%> 5 <%!public double getPriceSum(String input) { 6 Pattern pattern; 7 Matcher matcher; 8 String regex = "-?[0-9][0-9]*[.]?[0-9]*"; 9 pattern = Pattern.compile(regex); 10 matcher = pattern.matcher(input); 11 double sum = 0; 12 while (matcher.find()) { 13 String str = matcher.group(); 14 sum += Double.parseDouble(str); 15 } 16 return sum; 17 }%> 18 19 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 20 <html> 21 <head> 22 23 </head> 24 25 <body bgcolor="cyan"> 26 <p style="font-family:黑体;font-size:20"> 27 <br>张三的菜单: 28 <br> 29 <% 30 String str = "麻婆豆腐:20.6元,红烧肉:68.9"; 31 %> 32 <br><%=str%><br> <br> <b><i>消费总额:<%=getPriceSum(str)%></i><br> 33 </b> <br>李四的菜单:<br> 34 <% 35 str = "剁椒鱼头:62.9元,烤鸭:199元,红焖大虾:289.9元"; 36 %> 37 <br><%=str%><br> <br> <b><i>消费总额:<%=getPriceSum(str)%></i><br> 38 </b> 39 40 </p> 41 </body> 42 </html>
2.时间日期
1 <%@ page import = "java.time.LocalDate" %> 2 <%@ page import = "java.time.LocalTime" %> 3 <% 4 LocalDate date = LocalDate.now(); 5 LocalTime time = LocalTime.now(); 6 %> 7 <h2> 8 用户在 <%= date.getYear()%>/<%= date.getMonthValue()%>/<%= date.getDayOfMonth() %><br> 9 <%= time.getHour()%>:<%= time.getMinute()%>:<%= time.getSecond()%>访问了网页。 10 </h2>
1 <%@ page contentType="text/html" %> 2 <%@ page pageEncoding = "utf-8" %> 3 <HTML><body> 4 <h1>显示访问网页的日期、时间<br>(服务器端的日期、时间)</h1> 5 <%@ include file="time.jsp" %> 6 </body></HTML>
老师我的java版本是1.7的,localdate要java1.8的,包导不了,图片没弄...
3.听英语
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@ page contentType="text/html" %> 3 <HTML><body bgcolor=cyan > 4 <br>英文课文(English Text): 5 <p style="font-family:宋体;font-size:18;color:black"> 6 <jsp:include page="english/english.txt" /> 7 <br>课文音频(English Audio): 8 <jsp:include page="audio.jsp" /> 9 </p></body></HTML>
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <%@ page contentType="text/html" %> 3 <HTML><body bgcolor = pink > 4 <embed src = "english/english.mp3" autostart = false> 5 课文音频 6 </body></HTML>
1 Lesson 1 A private conversation 私人谈话 2 ---------------------------------------- 3 Last week I went to the theatre. 4 I had a very good seat. 5 The play was very interesting. 6 I did not enjoy it. 7 A young man and a young woman were sitting behind me. 8 They were talking loudly. 9 I got very angry. 10 I could not hear the actors. 11 I turned round.I looked at the man and the woman angrily. 12 They did not pay any attention. 13 In the end, I could not bear it. 14 I turned round again. 15 'I can't hear a word!' I said angrily. 16 It’s none of your business,' the young man said rudely. 17 'This is a private conversation!'.