目录

题目:实现一个计算教师工资的项目

项目目录结构


题目:实现一个计算教师工资的项目

项目目录结构

 页面一:Employee.java

package entitylogic;public abstract class  Employee {
String title;
float wage;
String name;
abstract void calculateWage();
public Employee(String name,String title)
{super();this.name=name;this.title=title;}
public String getTitle() {return title;
}
public void setTitle(String title) {this.title = title;
}
public float getWage() {return wage;
}
public void setWage(float wage) {this.wage = wage;
}
public String getName() {return name;
}
public void setName(String name) {this.name = name;
}}

页面二:FulltimeTeacher.java

package entitylogic;public class FulltimeTeacher extends Employee{float extrahours;float basicwage;public FulltimeTeacher(String name,String title){super(name, title);}public float getExtrahours() {return extrahours;}public void setExtrahours(float extrahours) {this.extrahours = extrahours;}public float getBasicwage() {return basicwage;}public void setBasicwage(float basicwage) {this.basicwage = basicwage;}public void calculateWage() {if(this.title.equals("副教授")) {this.basicwage=4000;wage=this.basicwage+this.extrahours*80;}else if(this.title.equals("教授")){this.basicwage=6000;wage=this.basicwage+this.extrahours*100;}}
}

页面三:Cal.java

package servlet;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import entitylogic.FulltimeTeacher;/*** Servlet implementation class Cal*/
@WebServlet("/Cal")
public class Cal extends HttpServlet {private static final long serialVersionUID = 1L;/*** @see HttpServlet#HttpServlet()*/public Cal() {super();// TODO Auto-generated constructor stub}/*** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubresponse.getWriter().append("Served at: ").append(request.getContextPath());}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {// TODO Auto-generated method stubtry {request.setCharacterEncoding("utf-8");response.setContentType("text/html;charset= utf-8");String name = request.getParameter("employeeName");String title = request.getParameter("employeeTitle");Float extraClasshour = Float.parseFloat(request.getParameter("employeeExtraClasshour"));FulltimeTeacher pt2 = new FulltimeTeacher(name, title);pt2.setExtrahours(extraClasshour);pt2.calculateWage();Float wage = pt2.getWage();ServletContext context = getServletContext();RequestDispatcher rd = context.getRequestDispatcher("/jsp/show.jsp?wage=" + wage);rd.forward(request, response);} catch (Exception ex) {PrintWriter out = response.getWriter();out.println("<html><head><title>");out.println("返回重填页面");out.println("</title></head><body>");out.println("出错了");out.println(ex.getMessage());String url = this.getServletContext().getContextPath()+"/jsp/input.jsp";out.println("<form action="+url+">");out.println("<input type=submit value=返回重填>");out.println("</form>");out.println("</body></html>");out.close();}}}

页面四:input.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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body><%String url=this.getServletContext().getContextPath()+"/Cal"; %><form  method=post action =<%=url %>><div style="text-align:center ">本院全职教师工资计算</div>请输入:<br>姓名: <input name ="employeeName" type ="text" ><br>职称:<input name ="employeeTitle" type ="radio" value="副教授" checked ="checked">副教授<input name ="employeeTitle" type ="radio" value="教授">教授<br>本月超额课时为:<input name ="employeeExtraClasshour" type ="text"><br><input name ="CalculateWage" type="submit" value = "计算"><input name ="reset" type="reset" value = "重填"><br></br></form>
</body>
</html>

页面五:show.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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%String name = request.getParameter("employeeName");float wage = Float.parseFloat(request.getParameter("wage"));%>以下是您提交的信息,请确认:<br><%=name%><br> 本月工资为:<%=wage%>
</body>
</html>

项目运行结果图

小项目:简单Web教师工资计算相关推荐

  1. java jsp教师工资计算_基于jsp的教师工资管理-JavaEE实现教师工资管理 - java项目源码...

    基于jsp+servlet+pojo+mysql实现一个javaee/javaweb的教师工资管理, 该项目可用各类java课程设计大作业中, 教师工资管理的系统架构分为前后台两部分, 最终实现在线上 ...

  2. 高校教师工资管理系统java_基于jsp+Spring+mybatis的SSM简单院校教师工资管理系统...

    运行环境: 最好是java jdk 1.8,我们在这个平台上运行的.其他版本理论上也可以. IDE环境: Eclipse,Myeclipse,IDEA都可以 硬件环境: windows 7/8/10 ...

  3. Linux C小项目 —— 简单的web服务器

    简单的Web服务器 实现一个基于HTTP通信协议的web服务器.客户端向服务器程序发送所需文件的请求,服务器端分析请求并将文件发送个客户端. 1.整体程序设计 客户端发送所需文件,服务器返回该文件,通 ...

  4. python游戏小项目简单_[简单学Python] 通过一个小游戏完成Python入门[2]变量和赋值...

    变量和赋值 到这里,你已经成功地打印出了千寻的名字和卖身契.与此同时,千寻也成为了汤婆婆的工人,渐渐地,她忘记了自己是谁,遗失了自己"姓名"的信息. 那么,在信息纷繁的代码世界里, ...

  5. Django小项目简单BBS论坛

    开发一个简单的BBS论坛 项目需求: 1 整体参考"抽屉新热榜" + "虎嗅网" 2 实现不同论坛版块 3 帖子列表展示 4 帖子评论数.点赞数展示 5 在线用 ...

  6. 通信基础篇小项目-----简单网络画板的的实现

    网络画板的开发也是基于通信基础.关于通信的体内容,在上一篇博客里面已经说过,这里不再多说.这里主要介绍一下该画板的实现过程.当然这三行代码还是核心内容. ServerSocket server = n ...

  7. android 小项目 简单项目 大作业 演示文档 结业 选修课 论文 答辩

  8. Python实战项目23个实战小项目小程序简单

    Python项目23个小项目简单 项目类别 部分项目运行截图 含代码注释 项目类别 51商城 AI智能联系人管理(双击即启动) BBS问答社区 DIY字符画(双击即启动) Excel数据分析师(双击即 ...

  9. 【java毕业设计】基于javaEE+原生servlet+tomcat的教师工资管理系统设计与实现(毕业论文+程序源码)——教师工资管理系统

    基于javaEE+原生servlet+tomcat的教师工资管理系统设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于javaEE+原生servlet+tomcat的教师工资管理系统设计与实 ...

最新文章

  1. [JAVA]寻找满足和的最短子序列(Minimum Size Subarray Sum)
  2. Go 语言 Excel
  3. svn提示out of date的解决方法
  4. 当你感到学习困难的时候,你在走上坡路!
  5. Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
  6. React开发(278):ant design message res保证正确信息提示
  7. Windows7下VS2008试用版到期的解决办法
  8. 表单+文件上传+音频+iframe
  9. MultipleRegularExpressionAttribute MVC中扩展自定义验证规则
  10. ios 判断手机角度_iPhone那么贵,为什么电池还那么小呢?安卓手机电池都那么大了!...
  11. linux图形界面漏洞,ManageEngine DesktopCentral任意文件上传漏洞(CVE-2014-5007)
  12. python科学计算最佳实践_Python科学计算最佳实践 SciPy指南:Python
  13. 服务器系统在虚拟机安装win7系统安装教程,虚拟机安装教程图解 虚拟机安装win7步骤...
  14. 巧得int(4字节)最大最小值
  15. (超详细)nessus下载与安装
  16. 第三方银联支付接口对接_php版银联支付接口开发简明教程
  17. OMML2MML.XSL 微软数学标记语言源码
  18. 华为运营商级路由器配置示例 | 配置OptionB方式跨域BGP VPLS示例(ASBR兼做PE)
  19. 有功功率,无功功率,视在功率定义
  20. c语言软件中ovr怎么取消,OVR Toolkit

热门文章

  1. 神经网络学习小记录47——ShuffleNetV2模型的复现详解
  2. CSS重要知识点汇总
  3. dbvisualizer 使用Database URL链接Sybase数据库方式
  4. 日历控件FullCalendar中文API
  5. task2-基于小鼠的基因集数据库资源
  6. 一键steam挂卡linux,如何在ubuntu server中通过ArchiSteamFarm挂卡
  7. .3dl.look.cube文件格式预设怎么使用?.3dl.look.cube文件怎么安装?
  8. vue跨域 Uncaught (in promise) Proxy error: Could not proxy request xxx from xxx to xxx (EPROTO)解决办法
  9. 张飞老师硬件第二十五部--马达驱动--原理图设计--下桥MOSFET的分立器件半桥设计
  10. keytool 查看apk 签名信息