Programming a calculator in Delphi

sarah04101988 Posted messages 1 Status Member -  
rooky06 Posted messages 20 Status Member -
Hello everyone,
please it's very urgent! I need to program a calculator for tomorrow
I managed to do it but I still need to program the sign change button (+/-), the square root button, and the division by 0.
Please help me.

1 answer

rooky06 Posted messages 20 Status Member 4
 
For changing the sign, you simply do

...onclick...
number=number*-1

for the square root it's here http://www.delphibasics.co.uk/RTL.asp?Name=Sqrt

regarding 0
If zero is divided, the result is always 0
if 0 is the divisor, it's an error

either you handle it with a try ... except
this is the case handled here http://www.delphibasics.co.uk/RTL.asp?Name=Except

otherwise simpler:
if divisor=0 then
exit
0