Calculator
Moderator: DosItHelp
Calculator
Hello everyone, I decided to make a fun tool, a simple calculator.
NOTE: I only programmed ADDITION to work (For now)
Looks like this:
Calculator Test
Enter First Value (Enter any number here then press enter)
Enter Second Value (Enter any number here then press enter)
"first number" + "second number" = "the result"
Try not to enter extremely high numbers or it will probably crash (Also, do not use letters!)
A little confession: This was coded in c++ but was programmed to run in CMD (Runs exactly like a batch file)
Well If you guys like it, I can keep working on it Thanks, and good day to you all!
NOTE: I only programmed ADDITION to work (For now)
Looks like this:
Calculator Test
Enter First Value (Enter any number here then press enter)
Enter Second Value (Enter any number here then press enter)
"first number" + "second number" = "the result"
Try not to enter extremely high numbers or it will probably crash (Also, do not use letters!)
A little confession: This was coded in c++ but was programmed to run in CMD (Runs exactly like a batch file)
Well If you guys like it, I can keep working on it Thanks, and good day to you all!
Re: Calculator
Calculator Link -- http://www.mediafire.com/?hqaj2g8x7237hrx
Re: Calculator
Great man, you totally should keep on playing around with batch if you enjoy it much ^_^
you should add something like this to make it a bit more advanced and more useful for different sums
so then you can do something like
%value% %i% %value2%
i dunno how calculating exactly work with batch but its defo possible :3
you should add something like this to make it a bit more advanced and more useful for different sums
Code: Select all
set i=
set /p i=[+ - / X]
so then you can do something like
%value% %i% %value2%
i dunno how calculating exactly work with batch but its defo possible :3
Re: Calculator
Judago wrote a couple of pure math batch files that can exceed the 32 bit integer limit of SET /A.
Re: Calculator
Yeah, I make remake one in Batch for fun But i'll probably add some more functionalities with my c++ version
Re: Calculator
Scythe wrote:Yeah, I make remake one in Batch for fun But i'll probably add some more functionalities with my c++ version
I appreciate your contribution but we do mainly just focus on batch files here.
-
- Posts: 22
- Joined: 18 Oct 2013 05:28
Re: Calculator
Code: Select all
:CalculatorProgram
@echo off
color C
:root
cls
echo ====================================
echo =Welcome To CMD Calculator by PROXY=
echo ====================================
echo Press 1,2 or 3 for menus
echo 1.) Calculator
echo 2.) Instructions
echo 3.) Info
set /p !=
if %!% == 1 goto Calculator
if %!% == 2 goto Instructions
if %!% == 3 goto Info
:Calculator
cls
color D
echo ======================
echo Previous Answer= %ans%
echo ----------------------
set /p sum=
set /a ans=%sum%
echo = %ans%
goto Calculator
set /p !=
cls
echo ==================================
echo Previous Answer %ans%
goto top
pause
:Instructions
cls
color A
echo To use calculator-
echo Insert Number N
echo use the + key to add
pause
echo use the - key to subtract
pause
echo use the * key to multiply
pause
echo use the / key to divide
pause
echo Got It? (y,n)
set /p !=
if %!% == Y goto root
if %!% == y goto root
if %!% == N goto Instructions
if %!% == n goto Instructions
pause
:Info
cls
echo ====================================
echo =Welcome To CMD Calculator by PROXY=
echo ====================================
color B
echo This calculator was created by Batch Artist
pause
echo Would you like to return to the main menu? (y,n)
set /p m=
if %m% == Y goto root
if %m% == y goto root
if %m% == N goto Info
if %m% == n goto Info
This will also work and this has multiplication, division, subtraction and addition.
Re: Calculator
I have a couple of comments, Batch Artist.
Using /i makes the compare case insensitive so you don't need multiple statements, and using double quotes protects against errors when no input is entered (and the variable is blank), as well as if two words were entered.
The other thing is that the ! as a variable name is ok where you use it, but it is better to avoid using it because when you use delayed expansion, the ! will fail.
Using /i makes the compare case insensitive so you don't need multiple statements, and using double quotes protects against errors when no input is entered (and the variable is blank), as well as if two words were entered.
Code: Select all
if /i "%m%"=="y" goto :yes
The other thing is that the ! as a variable name is ok where you use it, but it is better to avoid using it because when you use delayed expansion, the ! will fail.
Re: Calculator
Batch Artist,
Your script will not work with numbers larger than 2,147,483,647.
Your script will not work with numbers larger than 2,147,483,647.
-
- Posts: 22
- Joined: 18 Oct 2013 05:28
Re: Calculator
Squashman wrote:Batch Artist,
Your script will not work with numbers larger than 2,147,483,647.
Ahhh, I gotta look into that. Thank you!
-
- Posts: 22
- Joined: 18 Oct 2013 05:28
Re: Calculator
foxidrive wrote:I have a couple of comments, Batch Artist.
Using /i makes the compare case insensitive so you don't need multiple statements, and using double quotes protects against errors when no input is entered (and the variable is blank), as well as if two words were entered.Code: Select all
if /i "%m%"=="y" goto :yes
The other thing is that the ! as a variable name is ok where you use it, but it is better to avoid using it because when you use delayed expansion, the ! will fail.
I will keep all that in mind. Thank you very much Foxidrive!
Re: Calculator
Sorry about that everyone, I just figured out how to make all calculator elements into one Well, i'm going back to batch and i'll post some more projects here.
Re: Calculator
In this forum was a thread and there also a link to a calculator:
thread: http://www.dostips.com/forum/viewtopic.php?f=3&t=4279
link: http://judago.webs.com/batchfiles.htm
See there: STR_MATH.BAT
thread: http://www.dostips.com/forum/viewtopic.php?f=3&t=4279
link: http://judago.webs.com/batchfiles.htm
See there: STR_MATH.BAT