TGC Codebase Backup



quite powerful calculator by mm0zct

12th Dec 2003 13:04
Summary

it is a calculator that does powers, square roots, multiply, divide, add and subtract, also does sin, cos, tan, inv-sin/cos/tan



Description

it is a calculator program that will do multiplications, divisions, additions and subtraction, it also does powers and square roots. i had forgotten about the power command in db so i wrote the whole power coding myself but the square root is just the command from db, i could not get the power command to work anyway so it was not a total waste of time writing it out. it now does sin/cos/tan etc as in title. email me for help understanding it:
the_cartographer@hotmail.com



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    print "type your starting number please"
input t#
te#=t#
do
cls
print t#
print "chose an option"
print "(number will be displayed in scientific notation if too large)"
print "(this will be in the form eg: 1.123e+006, which would be 1.123*10^6)"
print ""
print "1:add"
print "2:subtract"
print "3:divide"
print "4:multiply"
print "5:multiply current number power"
print "6:square root"
print "7:tan"
print "8:tan-1"
print "9:sin"
print "10:sin-1"
print "11:cos"
print "12:cos-1"
print "0:quit"
input c
select c
case 1
gosub add
endcase
case 2
gosub subtract
endcase
case 3
gosub divide
endcase
case 4
gosub multiply
endcase
case 5
gosub power
endcase
case 6
gosub square_root
endcase
case 7
gosub tant
endcase
case 8
gosub invtan
endcase
case 9
gosub sint
endcase
case 10
gosub invsin
endcase
case 11
gosub cost
endcase
case 12
gosub invcos
endcase
case 0
goto quit
endcase
endselect
loop

add:
print "enter the number you want to add"
input a#
t#=t#+a#
return

subtract:
print "enter the number you want to subtract"
input s#
t#=t#-s#
return


divide:
print "enter the number you want to divide by"
input d#
if d#<>0
t#=t#/d#
endif
if d#=0
print "division by zero is imposible"
wait key
endif
if d#<>0
te#=te#/d#
endif
return

multiply:
print "enter the number you want to multiply by"
input m#
t#=t#*m#
te#=te#*m#
return

power:
rem:i know this in not theoretically the best way to do this
rem:but it works better than the exp comand(i have had some problems with it)
tp#=t#
tp2#=te#
print "enter the power (power must be integer only)"
input p
if p>=2
p=p-1
for i=1 to p step 1
tp#=tp#*t#
tp2#=tp2#*te#
next i
endif
if p=1
endif
if p=0
tp#=1
tp2#=1
endif
if p<=-1
for i=0 to p step -1
tp#=tp#/t#
tp2#=tp2#/te#
next i
endif
t#=tp#
te#=tp2#

return

square_root:
if t#=>0
tr#=sqrt(t#)
tr2#=sqrt(te#)
t#=tr#
te#=tr2#
endif
if t#<0 then print "you cannot squareroot a negative" : wait key
return

tant:
print "warning, this is not an exact result, press a key to continue"
wait key
tant#=tan(te#)
te#=tant#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

invtan:
print "warning, this is not an exact result, press a key to continue"
wait key
tant#=atan(te#)
te#=tant#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

sint:
print "warning, this may not be an exact result, press a key to continue"
wait key
sint#=sin(te#)
te#=sint#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

invsin:
print "warning, this may not be an exact result, press a key to continue"
wait key
sint#=asin(te#)
te#=sint#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

cost:
print "warning, this may not be an exact result, press a key to continue"
wait key
cost#=cos(te#)
te#=cost#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

invcos:
print "warning, this may not be an exact result, press a key to continue"
print "the valu has been rounded because of in accuracies"
wait key
cost#=acos(te#)
te#=cost#
t#=te#
t#=1000*t#
t#=int(t#)
t#=t#/1000
return

quit:
cls
print "thank you for using my program"
print "press any key to quit"
wait key