1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

MS-DOS Batch Calculator

Discussion in 'DOS/Other' started by goofman, Sep 4, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. goofman

    goofman Thread Starter

    Joined:
    Sep 4, 2004
    Messages:
    47
    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!!! :confused:
     
  2. goofman

    goofman Thread Starter

    Joined:
    Sep 4, 2004
    Messages:
    47
    oops, wrong forum isnt it, is hould be in da xp one
     
  3. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,731
  4. goofman

    goofman Thread Starter

    Joined:
    Sep 4, 2004
    Messages:
    47
    :D omg, thank you so much!
     
  5. nik62591

    nik62591

    Joined:
    Oct 27, 2004
    Messages:
    1
    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
     
  6. goofman

    goofman Thread Starter

    Joined:
    Sep 4, 2004
    Messages:
    47
    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 :D

    thank you so much man
     
  7. Sponsor

As Seen On
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/270094