0 Replies - 1107 Views - Last Post: 08 December 2009 - 07:59 AM

#1 VulcanDesign  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 98
  • Joined: 06-December 09

BATCH Calculator

Posted 08 December 2009 - 07:59 AM

Description: Simply copy the code to a program like Notepad, and save as yourname.batThis is the code for a simple calculator capable of doing addition, subtraction, multiplication, and division. It also has a very simple user interface. It is written in BATCH.
@echo off
title Simple Calculator
echo Welcome to this Simple Calculator. With this calculator, you can preform basic addition, subtraction, division, and multiplication.
pause
cls
:start
echo -----
echo Simple Calculator
echo ....................
echo Please preform one of the following functions:
echo .
echo 1: Clear calculator
echo 2: Addition
echo 3: Subtraction
echo 4: Multiplication
echo 5: Division
echo 6: Exit program
set /p choice=  Please select your choice:  
if %choice% EQU 1 goto :clear
if %choice% EQU 2 goto :addition
if %choice% EQU 3 goto :subtraction
if %choice% EQU 4 goto :multiplication
if %choice% EQU 5 goto :division
if %choice% EQU 6 goto :exit
cls 
goto :start

:clear
cls
goto :start

:addition
cls
echo ADDITION
echo .
set /p num1=Number: 
echo +
set /p num2=Number: 
set /a ans=%num1%+%num2%
echo %num1% + %num2% = %ans%
pause
goto :start

:subtraction
cls
echo SUBTRACTION
echo .
set /p num1=Number: 
echo -
set /p num2=Number: 
set /a ans=%num1%-%num2%
echo %num1% - %num2% = %ans%
pause
goto :start

:multiplication
cls
echo MULTIPLICATION
echo .
set /p num1=Number: 
echo X
set /p num2=Number: 
set /a ans=%num1%*%num2%
echo %num1% x %num2% = %ans%
pause
goto :start

:division
cls
echo DIVISION
echo .
set /p num1=Number: 
echo /
set /p num2=Number: 
set /a ans=%num1%/%num2%
echo %num1%/%num2% = %ans%
pause
goto :start

:exit
echo Thank you for using Simple Calculator
pause
:eof


Is This A Good Question/Topic? 1
  • +

Page 1 of 1