Pair of Problems
- Posted by David Shane <DSDUDE1116 at AOL.COM> Sep 20, 1998
- 566 views
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 ------------------------------