Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.util.Log;

public class Main {
    public static float compute(String op1, String op2, char operator) {

        float o1 = Float.parseFloat(op1);
        float o2 = Float.parseFloat(op2);

        Log.e("Operand 1", op1);
        Log.e("Operand 2", op2);
        Log.e("Operator", operator + "");

        switch (operator) {
        case '-':
            return (o1 - o2);
        case '+':
            return (o1 + o2);
        case '/':
            return (o1 / o2);
        case '*':
            return (o1 * o2);
        default:
            break;
        }
        return -1;
    }
}