# MS-DOS Batch Calculator



## goofman (Sep 4, 2004)

hi all, im creating a batch file calculator...except when i run it and type in something like 3+2e the answer doesnt come up, o yea, it only goes up to 10 caus ethats a lot of typing! but i--o nvm, its hard to explain, heres the code!!:
echo off
title Calculator
cls
:start
echo. 
echo. 
echo 1 2 3 
echo. 
echo 4 5 6 
echo. 
echo 7 8 9 
echo. 
echo 0
echo + - 
echo. 
echo e
echo. 
set choice:
set /p choice= Just use this like a normal Calculator...NOTE: e= Equals 
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='0+0e0' echo 0
if '%choice%'=='1+0e1' echo 1
if '%choice%'=='0+1e1' echo 1
if '%choice%'=='2+0e2' echo 2
if '%choice%'=='0+2e2' echo 2
if '%choice%'=='1+2e3' echo 3
if '%choice%'=='2+1e3' echo 3
if '%choice%'=='3+0e3' echo 3
if '%choice%'=='4+0e4' echo 4
if '%choice%'=='3+1e4' echo 4
if '%choice%'=='1+3e4' echo 4 
if '%choice%'=='2+2e4' echo 4
if '%choice%'=='2+3e5' echo 5
if '%choice%'=='3+2e5' echo 5
if '%choice%'=='4+1e5' echo 5
if '%choice%'=='1+4e5' echo 5
if '%choice%'=='5+0e5' echo 5
if '%choice%'=='5+1e6' echo 6
if '%choice%'=='1+5e6' echo 6
if '%choice%'=='4+2e6' echo 6
if '%choice%'=='2+4e6' echo 6
if '%choice%'=='3+3e6' echo 6
if '%choice%'=='6+0e6' echo 6
if '%choice%'=='0+6e6' echo 6
if '%choice%'=='6+1e7' echo 7
if '%choice%'=='1+6e7' echo 7
if '%choice%'=='5+2e7' echo 7
if '%choice%'=='2+5e7' echo 7
if '%choice%'=='4+3e7' echo 7
if '%choice%'=='3+4e7' echo 7 
if '%choice%'=='7+0e7' echo 7
if '%choice%'=='0+7e7' echo 7
if '%choice%'=='7+1e8' echo 8
if '%choice%'=='1+7e8' echo 8
if '%choice%'=='5+3e8' echo 8
if '%choice%'=='3+5e8' echo 8
if '%choice%'=='4+4e8' echo 8
if '%choice%'=='6+2e8' echo 8
if '%choice%'=='2+6e8' echo 8
if '%choice%'=='8+0e8' echo 8
if '%choice%'=='0+8e8' echo 8
if '%choice%'=='9+0e9' echo 9
if '%choice%'=='0+9e9' echo 9
if '%choice%'=='8+1e9' echo 9
if '%choice%'=='1+8e9' echo 9
if '%choice%'=='7+2e9' echo 9
if '%choice%'=='7+2e9' echo 9
if '%choice%'=='6+3e9' echo 9
if '%choice%'=='3+6e9' echo 9
if '%choice%'=='5+4e9' echo 9
if '%choice%'=='4+5e9' echo 9
if '%choice%'=='10+0e10' echo 10 
if '%choice%'=='0+10e10' echo 10
if '%choice%'=='9+1e10' echo 10 
if '%choice%'=='1+9e10' echo 10
if '%choice%'=='8+2e10' echo 10
if '%choice%'=='2+8e10' echo 10 
if '%choice%'=='7+3e10' echo 10
if '%choice%'=='3+7e10' echo 10
if '%choice%'=='4+6e10' echo 10
if '%choice%'=='6+4e10' echo 10
if '%choice%'=='5+5e10' echo 10
:0+0e0 
goto start
:1+0e1 
goto start
:0+1e1 
goto start
:2+0e2
goto start
:0+2e2 
goto start
:1+2e3 
goto start
:2+1e3
goto start
:3+0e3 
goto start
:4+0e4 
goto start
:3+1e4 
goto start
:1+3e4 
goto start
:2+2e4 
goto start
:2+3e5 
goto start
:3+2e5 
goto start
:4+1e5 
goto start
:1+4e5 
goto start
:5+0e5 
goto start
:5+1e6 
goto start
:1+5e6 
goto start
:4+2e6
goto start
:2+4e6 
goto start
:3+3e6 
goto start
:6+0e6 
goto start
:0+6e6 
goto start
:6+1e7 
goto start
:1+6e7 
goto start
:5+2e7 
goto start
:2+5e7 
goto start
:4+3e7 
goto start
:3+4e7 
goto start
:7+0e7 
goto start
:0+7e7 
goto start
:7+1e8 
goto start
:1+7e8 
goto start
:5+3e8 
goto start
:3+5e8 
goto start
:4+4e8 
goto start
:6+2e8 
goto start
:2+6e8 
goto start
:8+0e8 
goto start
:0+8e8 
goto start
:9+0e9 
goto start
:0+9e9 
goto start
:8+1e9
goto start
:1+8e9 
goto start
:7+2e9 
goto start
:7+2e9 
goto start
:6+3e9 
goto start
:3+6e9 
goto start
:5+4e9
goto start
:4+5e9 
goto start
:10+0e10 
goto start
:0+10e10 
goto start
:9+1e10 
goto start
:1+9e10 
goto start
:8+2e10 
goto start
:2+8e10 
goto start
:7+3e10 
goto start
:3+7e10 
goto start
:4+6e10 
goto start
:6+4e10 
goto start
:5+5e10 
goto start


so whats wrong, how come the answer doesnt show uP!!!


----------



## goofman (Sep 4, 2004)

oops, wrong forum isnt it, is hould be in da xp one


----------



## Squashman (Apr 4, 2003)

Might want to take a look at this.
http://www.pressroom.com/~tglbatch/realmath.html


----------



## goofman (Sep 4, 2004)

omg, thank you so much!


----------



## nik62591 (Oct 27, 2004)

Hello, The reason your calculator does not show the answer is because in the if commands, you put for example, you would specify the answer by asking if the string you have entered is equal to the string there, and if so, display its answer, how ever for 1+1e2 for examplem, the person typing the message into the calculator would only type 1+1e because they do not know that 2 is the answer. so take out the answer in the if conissionals to make them 1+1e echo 2
i am not sure why upi have labels for each individual number along with the if. 
I actually made a calculator, because i am 13 years old, and it would be cool to have one for nschool (even though I can use calculator in windows). I googled and found you because I wanted to know why my calculator doesn't process decimals.
Try te answer above, or try my calculator which does multiplication, devision, addition, and subtraction.
works with negitives, orders of operation.
I know the set feture does most of the work, but here's the code so you can copy it to a batch script.
Thanks






title Simple calculator
@echo off
:calculate
cls
echo enter a math problem
set /p calc="Problem: "
set /a answer=%calc%
cls
echo %calc% = 
echo %answer%
echo.
echo.
echo.
echo to abort, type ctrl+break.
echo otherwise,
pause
goto calculate


----------



## goofman (Sep 4, 2004)

yikes! im 13 too, but, i can't beleive i didnt see the problem and why i didnt use your method! well, actually, to tell you the truth, i was making this like right when i started making batch programs  

thank you so much man


----------

