【javaweb】javabean-四则运算

oprator.java

package lyy;

public class oprator {
	private float first;
	private float second;
	private String op;
	private float result;
	
	public float getFirst() {
		return first;
	}
	public void setFirst(float first) {
		this.first = first;
	}
	public float getSecond() {
		return second;
	}
	public void setSecond(float second) {
		this.second = second;
	}
	
	
	public String getOp() {
		return op;
	}
	public void setOp(String op) {
		this.op = op;
	}
	public float getResult() {
		if (op.equals("+")) {
			result = first+second;
		}
		if (op.equals("-")) {
			result = first-second;
		}
		if (op.equals("*")) {
			result = first*second;
		}
		if (op.equals("/") && second != 0) {
			result = first/second;
		}
		return result;
	}
	public void setResult(float result) {
		this.result = result;
	}
	

}



op.jsp

<%@ page contentType="text/html" pageEncoding="UTF-8"%>






Oprator the two number



name = "first"> name = "second"> <%if (opra.getSecond() == 0 && opra.getOp().equals("/")){ %> no result
<%}else{%> =
<%}%> =

【javaweb】javabean-四则运算_第1张图片
【javaweb】javabean-四则运算_第2张图片

【javaweb】javabean-四则运算_第3张图片

你可能感兴趣的:(前后端,java,前端)