Thursday, December 21



Making calculations using Windows calculator can get tedious. 
In this article, I'll tell you how to create your's personal calculator in a few seconds. 
Today let us try building our own command prompt calculator.

The following steps help you in building a simple calculator.

Step 1:

Press Windows logo + R on the keyboard, it will launch the Run window.


Type Notepad and press enter.

Step 2

 Copy the following code and paste it into the notepad.

@echo off
title Basic Calculator by Kiran
color 3f
:top
echo --------------------------------------------------------------
echo Welcome to Basic Calculator  
echo --------------------------------------------------------------
echo. 
set /p sum=
set /a ans=%sum%
echo. 
echo = %ans%
echo --------------------------------------------------------------
pause
cls
echo Previous Answer: %ans%
goto top
pause
exit




Note:

1. Use the format (without quotes as in the above code) title xxx in the above code have your own title. 

2. change the background and the font colour of the calculator
considering  2 hex digits — the first corresponds the background; the second the foreground. Each digit will follow the following values:

0 = Black, 1 = Blue, 2 = Green, 3 = Aqua, 4 = Red, 5 = Purple, 6 = Yellow, 7 = White, 8 = Gray, 9 = Light Blue
 A = Light Green, B = Light Aqua, C = Light Red, D = Light Purple, E = Light Yellow, F = Bright White

Ex: In the code, we have used 3f. This means, the background colour will be Aqua and the font colour will be Bright white.
Like the above example, you can have your own colour combinations. The format is colour XX. 
                 -> XX represents the colour combinations.

Step 3

Now Save Notepad in  .bat format



Note: 
1. It can only handle integers and those of a specific number of digits. It doesn’t handle complex equations.
2. What is .bat?
.bat is an extension of batch files. A batch file is a text file that contains many commands for a computer’s operating system.

Step 4

Double-click on a file you have created. 


A command line based calculator will appear on the screen. 


Step 5:

To calculate, type the number and press enter. You will see the answer.


Step 6:

Press any key to clear the previous calculation. Continue calculating with a different set of numbers. It will then display the answer of the previous calculation at the starting of the screen.


Conclusion: 

Like this, you can create your own calculator and use this in your Day-to-day life.

Please comment on this post. If you like this post, please like and share this post.

Kiran's Blog . 2017 Copyright. All rights reserved. Designed by Blogger Template | Free Blogger Templates