package workshop1;

import java.util.Scanner;

/**
 *
 * @author Chichtorya
 */
public class Part2 {

    public static void main(String[] args) {
        Scanner InPut = new Scanner(System.in);
        System.out.print("Input the number 1: ");
        float Num1 = InPut.nextFloat();
        System.out.print("Input the number 2: ");
        float Num2 = InPut.nextFloat();
        System.out.print("Input the number 3: ");
        
        float Num3 = InPut.nextFloat();
        char ope1, ope2;
        System.out.print("Input the operator 1: ");
        ope1 = InPut.next().charAt(0);
        System.out.print("Input the operator 2: ");
        ope2 = InPut.next().charAt(0);
        float result = 0;
        if (((int) ope2 == 42 || (int) ope2 == 47) && ((int) ope1 == 43 || (int) ope1 == 45)) {
            result = cal(cal(Num2, Num3, (char) ope2), Num1, ope1);

        } else {
            result = cal(cal(Num1, Num2, (char) ope1), Num3, ope2);
        }
        System.out.print(Num1 +""+ ope1 +""+ Num2 +""+ ope2 +""+  Num3 + "=" + result);
        
    }

    public static float cal(float a, float b, char c) {

        float result = 0;
        switch (c) {

            case '+':
                result = a + b;

                break;

            case '-':
                result = a - b;

                break;

            case '*':
                result = a * b;

                break;

            case '/':
                result = a / b;

                break;

            default:
                System.out.println("Invalid operator!");
                break;
        }
        return result;
    }

}