Simple calculator in JM-

Here's a simple calculator made in JM-, also check out the argument-based version

// Simple JM- Calculator Example
str num1, num2; char op;
con.out{<< "Enter the first number: "};
con.readline{>> num1};
con.out{<< "\nEnter the operator: "};
con.readline{>> op};
con.out{<< "\nEnter the second number: "};
con.readline{>> num2};

switch.char(op) {
    1*'+':
        con.out{<< num1 + num2};
        sgo;
    2*'-':
        con.out{<< num1 - num2};
        sgo;
    3*'x'||'*':
        con.out{<< num1 * num2};
        sgo;
    4*'/'||':':
        con.out{<< num1 / num2};
        sgo;
    default:
        con.out{<< "Invalid operator :("};
        sgo;
};

Last updated