Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package corso.java.springapp.business;
- public class Calculator {
- private float first;
- private float second;
- private float result;
- private char op;
- public Calculator(float first, float second, char op) {
- this.first = first;
- this.second = second;
- this.op = op;
- execute(op);
- }
- private void execute(char operation) {
- switch (operation) {
- case '+':
- result = first + second;
- break;
- case '-':
- result = first - second;
- break;
- case '*':
- result = first * second;
- break;
- case '/':
- result = first / second;
- break;
- default:
- break;
- }
- }
- 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 float getResult() {
- return result;
- }
- public void setResult(float result) {
- this.result = result;
- }
- public char getOp() {
- return op;
- }
- public void setOp(char op) {
- this.op = op;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement