1.客户说:帮我开发一个复利计算软件。
完成复利公式计算程序,并成功PUSH到github上。
截止时间:3.10晚12点之前。
按照这个要求完成了。
演示。
计算:本金为100万,利率或者投资回报率为3%,投资年限为30年,那么,30年后所获得的利息收入:按复利计算公式来计算就是:1,000,000×(1+3%)^30
客户提出:
2.如果按照单利计算,本息又是多少呢?
3.假如30年之后要筹措到300万元的养老金,平均的年回报率是3%,那么,现在必须投入的本金是多少呢?
完成23功能,并成功PUSH到github上。
截止时间:3.12晚11点之前
记得更新进度条。
另外,是否预感到客户会有进一步的要求,而在下次会面演示之前有所准备呢?
以下是 index.jsp 主要客户端 代码 :
<%--Created by IntelliJ IDEA.User: pcDate: 2016/3/11Time: 20:46To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html><head><title>Compound Interest</title><style type="text/css">body{color : rgba(33, 157, 196, 0.8);font-size : 50px;margin: 20px auto;;}</style><script type="text/javascript">function check(form){if (document.forms.compoundInterest.principal.value == ""){alert("请输入本金 !");document.forms.compoundInterest.principal.focus();return false;}if (document.forms.compoundInterest.interestRate.value == ""){alert("请输入利率 !");document.forms.compoundInterest.interestRate.focus();return false;}if (document.forms.compoundInterest.year.value == ""){alert("请输入年份 !");document.forms.compoundInterest.year.focus();return false;}}</script></head><body><form action="<%=request.getContextPath()%>/InterestRateServlet" method="post" name="compoundInterest"><table bgcolor="1" cellpadding="0" cellspacing="5" border="silver" align="center"><tr><td align="center">本金 : </td><td><input type="text" name="principal"/></td></tr><tr><td align="center">利率 : </td><td><input type="text" name="interestRate"/></td></tr><tr><td align="center">年份 : </td><td><input type="text" name="year"/></td></tr><tr><td>利息类型 :</td><td><input type="radio" name="interest" value="compound"/>复利<input type="radio" name="interest" value="single"/>单利</td></tr><tr><td colspan="2" align="center"><input type="submit" name="提交" οnclick="return check(this);"/><input type="reset" name="重置"/></td></tr></table></form></body>
</html>
以下是 InterestRateSe 主要 服务端 代码 :
package Servlet;import Model.Interest;import Service.OrInterestService;import javax.servlet.RequestDispatcher; 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 java.io.IOException;/*** Created by pc on 2016/3/11.*/ public class InterestRateServlet extends HttpServlet {/** 创建 interest* :本金 利率 年份* */private Interest interest = new Interest();/** post 方法* */protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {interest.setPrincipal(Integer.parseInt(request.getParameter("principal")));interest.setInterest(Double.parseDouble(request.getParameter("interestRate")));interest.setYear(Integer.parseInt(request.getParameter("year")));OrInterestService orInterestService = new OrInterestService();// I_InterestService compoundInterestService = new SingleInterestService(); // System.out.println(compoundInterestService.calculate(interest)); String compound = orInterestService.orInterest(request.getParameter("interest"),interest);if(compound != null ){request.getSession().setAttribute("compound",compound);RequestDispatcher rd = request.getRequestDispatcher("/Jsp/successInterest.jsp");rd.forward(request,response);}}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doPost(request,response);} }