I. the requirement is as follows: use jsp to implement an ultra-simple web calculator. II. implementation 2. code Calculator. java copy code package com. amos. model; import java. math. bigDecimal;/*** @ ClassName: Calculator * @ Description: Calculator * @ author: amosli * @ email: amosli@infomorrow.com * @ date Mar 20,201 4 1:04:59 AM */public class Calculator {private String firstnum = "0"; private String secondnum = "0"; private char operator = '+ '; private String result; public String getResult () {r Eturn result;} public char getOperator () {return operator;} public void setOperator (char operator) {this. operator = operator;} public void setResult (String result) {this. result = result;} public String getFirstnum () {return firstnum;} public void setFirstnum (String firstnum) {this. firstnum = firstnum. trim ();} public String getSecondnum () {return secondnum;} public void setSecondnum (St Ring secondnum) {this. secondnum = secondnum. trim ();} public void calculate () {BigDecimal a = new BigDecimal (this. firstnum); BigDecimal B = new BigDecimal (this. secondnum); switch (this. operator) {case '+': this. result =. add (B ). toString (); break; case '-': this. result =. subtract (B ). toString (); break; case '*': this. result =. multiply (B ). toString (); break; case '/': if (B. doubleValue () = 0 ){ Throw new RuntimeException ("the divisor cannot be zero");} this. result =. divide (B, 10, BigDecimal. ROUND_HALF_DOWN ). toString (); break; default: break ;}} copy the code calculator. jsp copy Code <% @ 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>