Batch Calculator

by dfess in Circuits > Microsoft

58 Views, 1 Favorites, 0 Comments

Batch Calculator

download.png

In this tutorial, you will make a working calculator using batch file. It has speech functions as well!

Code

download.jpeg

Copy this code into notepad, and save it as [put the name you want here].bat. Remember to add a .bat at the end or it will not work. Then save as "all files" to your desktop.

CODE BELOW

@ echo off

title Batch Calculator

color 02

echo -------------------------

echo Batch Calculator

echo -------------------------

pause

cls

:start

echo Enter Calculation:

set num=%random%

::gets question

set /p calc=

::solves it

set /a ans=%calc%

::makes text to speech temp file

if exist temp%num%.vbs goto start

echo ' > "temp%num%.vbs"

echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs"

echo speech.speak "the answer is %ans%" >> "temp%num%.vbs"

start temp%num%.vbs

pause

::deletes temp file

del temp%num%.vbs

echo.

::answers it

echo = %ans%

pause

cls

::shows previous answer

echo Previous Answer %ans%

goto start

pause >nul

CODE ABOVE

Done

You are done, remember the symbols for the operations. +=addition -=subtraction *=multiplication /=division. To get the answer press enter.