Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

MS-DOS Batch Calculator


(!)

goofman's Avatar
goofman goofman is offline
Member with 47 posts.
THREAD STARTER
 
Join Date: Sep 2004
Location: u.s. *****
Experience: In the middle.
04-Sep-2004, 12:34 PM #1
Angry MS-DOS Batch Calculator
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's Avatar
goofman goofman is offline
Member with 47 posts.
THREAD STARTER
 
Join Date: Sep 2004
Location: u.s. *****
Experience: In the middle.
04-Sep-2004, 12:38 PM #2
oops, wrong forum isnt it, is hould be in da xp one
Squashman's Avatar
Trusted Advisor with 19,633 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
05-Sep-2004, 07:49 PM #3
Might want to take a look at this.
http://www.pressroom.com/~tglbatch/realmath.html
goofman's Avatar
goofman goofman is offline
Member with 47 posts.
THREAD STARTER
 
Join Date: Sep 2004
Location: u.s. *****
Experience: In the middle.
09-Sep-2004, 09:04 PM #4
yay
omg, thank you so much!
nik62591's Avatar
nik62591 nik62591 is offline
Junior Member with 1 posts.
 
Join Date: Oct 2004
Experience: Intermediate
27-Oct-2004, 04:57 PM #5
nik62591 - I have your ms-dos calculator answer of why the answer doesn't show up.
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's Avatar
goofman goofman is offline
Member with 47 posts.
THREAD STARTER
 
Join Date: Sep 2004
Location: u.s. *****
Experience: In the middle.
28-Oct-2004, 10:06 PM #6
Thank you
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
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑