Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Easy Mathematic

Hallo, I‘am a new member. Have no skills with the program.
I‘am looking for an simple example code for input numbers, calculate ( „+“ or other operations) and
Print the result.
How can I run a finished „program“ alone?
Thanks Bernd555

Comments

  • dave1707dave1707 Mod
    Posts: 7,200

    Hi @Bernd555 Here’s a program to add, subtract, multiply, and divide 2 numbers. Enter a number in the 2 input boxes and tap Calc. This is really simple and doesn’t come close to what Codea can do.

    function setup()
        parameter.text("Number1")
        parameter.text("Number2")
        parameter.action("Calc",calc)  
    end
    
    function calc()
        output.clear()
        print(Number1.." + "..Number2.." = "..Number1+Number2)
        print(Number1.." - "..Number2.." = "..Number1-Number2)
        print(Number1.." x "..Number2.." = "..Number1*Number2)
        print(Number1.." / "..Number2.." = "..Number1/Number2)
    end
    
  • dave1707dave1707 Mod
    edited January 5 Posts: 7,200

    Here’s another example. Just enter the expression and press Calc. See the 2 examples for syntax.

    function setup()
        parameter.text("expression")
        parameter.action("Calc",calc)
        print("example  23.4*12.8")
        print("example  45/9+34.6-6/2")
    end
    
    function calc()
        loadstring("a="..expression)()
        print(expression.." = "..a)
    end
    
  • Posts: 2

    Hi dave1707 Thanks for your answer.

Sign In or Register to comment.