1. Pair of Problems

Hello!  I making a calculator that will eventually handle sine, cos, etc., but
I have a couple problems with it.  I don't know how to get it to handle 2
digit numbers.  When I enter a number, it goes straight to asking me what the
next one is.  The other problem I wrote below.  Below is the part of my code
where you input the numbers.

------------------------
constant SCREEN = 1
clear_screen()
    include graphics.e
puts (SCREEN, "Enter first number.")
object i
    include get.e
i = wait_key() - 48  -- For some reason if I entered 1, it took it as 49, 2 as
50, etc.
? i  -- print the number entered
puts (SCREEN, "Enter second number.")
object y
    include get.e
y = wait_key() - 48
? y
atom z
object x
object w
object j
object b
object c
object A
object B
if i = 0 or y = 0 then
    puts (SCREEN, "Can't divide by zero!!\n")
    else
    puts (SCREEN, "Dividing first number by second.\n")
        z = y / i
? z
    puts (SCREEN, "Dividing second number by first.\n")
        b = i / y
? b
    puts (SCREEN, "Addition\n")
        x = y + i
? x
    puts (SCREEN, "Multiplication\n")
        w = y * i
? w
    puts (SCREEN, "Subtract second number from first.\n")
        j = y - i
? j
    puts (SCREEN, "Subtract first number from second.\n")
        c = i - y
? c
    puts (SCREEN, "Square root of first number.\n")
        A = sqrt (i)
? A
    puts (SCREEN, "Square root of second number.\n")
        B = sqrt (y)
? B
end if
------------------------------

new topic     » topic index » view message » categorize

2. Re: Pair of Problems

use get instead of wait_key. That's what I did in my calculator. Besides,
i don't think you'll need any of the routines in graphics.e, so turn it
into a comment.

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu