Friday

How to Make Calculator using Command Prompt (cmd)



For those readers who are interested in programming, here is a tutorial to program a simple calculator using batch file.


Step 1. Open Notepad.

Step 2. Paste the following code in Notepad.



@ECHO OFF
color 0a
title CALCULATOR
ECHO Calculator Version 1.2
ECHO Created by computergyd.blogspot.com
pause
ECHO ---------------------------------------- -------
ECHO Symbols for calculation -
ECHO * = MULTIPLY
ECHO + = ADD
ECHO - = SUBTRACT
ECHO / =DIVIDE
ECHO ---------------------------------------- -------
pause

:loop
echo.
echo ---------------------------------------- -------
SET /p UDefine=
SET /a UDefine=%UDefine%
ECHO =
ECHO %UDefine%
ECHO.
goto loop


Step 3. Save the file as name.bat.

You can replace name with any name you like.

Step 4. Open the file and your calculator is ready to use.


Also Read : Convert fat32 to ntfs without formatting or losing data


You can try this method to create calculator using HTML code.


Step 1. Open Notepad.

Step 2. Paste the following code in Notepad.


<html>
<head>
<title>Calculator</title>
</head>
<body>
<form name="calculator" >
Solution<br><input type="textfield" name="cal" value="">
<br>
<input type="button" value="1" 
onClick="document.calculator.cal.value+='1'">
<input type="button" value="2" 
onClick="document.calculator.cal.value+='2'">
<input type="button" value="3" 
onClick="document.calculator.cal.value+='3'">
<input type="button" value="+" 
onClick="document.calculator.cal.value+='+'">
<br>
<input type="button" value="4" 
onClick="document.calculator.cal.value+='4'">
<input type="button" value="5" 
onClick="document.calculator.cal.value+='5'">
<input type="button" value="6" 
onClick="document.calculator.cal.value+='6'">
<input type="button" value="-" 
onClick="document.calculator.cal.value+='-'">
<br>
<input type="button" value="7" 
onClick="document.calculator.cal.value+='7'">
<input type="button" value="8" 
onClick="document.calculator.cal.value+='8'">
<input type="button" value="9" 
onClick="document.calculator.cal.value+='9'">
<input type="button" value="*" 
onClick="document.calculator.cal.value+='*'">
<input type="button" value="/" 
onClick="document.calculator.cal.value+='/'">
<br>
<input type="button" value="0" 
onClick="document.calculator.cal.value+='0'">
<input type="reset" value="Reset">
<input type="button" value="=" 
onClick="document.calculator.cal.value=eval(document.calc
ulator.cal.value)">
</form>
</body>
</html>



Step 3. Save the file as name.html.

You can replace name with any name you like.

Step 4. Open the file and your calculator is ready to use.



If you like this article, share this article with your friends and share your experience with other readers.



No comments:

Post a Comment