Batch script to simulate a calculator

HEROSKING -  
little boy62 Posted messages 4393 Registration date   Status Membre Last intervention   -

Hello,

Help me, I am a beginner

Explain to me how to create a batch file that simulates the operation of a calculator for integer numbers


1 réponse

barnabe0057 Posted messages 14431 Registration date   Status Contributeur Last intervention   4 929
 

Hello,

Give your code and explain where you are stuck.


0
brucine Posted messages 24494 Registration date   Status Membre Last intervention   4 114
 

Hello,

Like this?

@echo off CHCP 65001>nul :START ECHO. SET /P un=Enter first number: SET /P deux=Enter second number: ECHO. CHOICE /C:ASDM /M "Enter the letter of the operation, (A)ddition, (S)ubtraction, (D)ivision, (M)ultiplication:" IF %ERRORLEVEL% EQU 4 GOTO MULTIPLICATION IF %ERRORLEVEL% EQU 3 GOTO DIVISION IF %ERRORLEVEL% EQU 2 GOTO SUBTRACTION IF %ERRORLEVEL% EQU 1 GOTO ADDITION :SUITE CHOICE /C:ON /M "Do you want to perform another operation, (Y)es or (N)o:" IF %ERRORLEVEL% EQU 2 GOTO END IF %ERRORLEVEL% EQU 1 GOTO START :MULTIPLICATION SET /A mult=%un%*%deux% ECHO. ECHO %un% x %deux% = %mult% ECHO. GOTO SUITE :DIVISION IF %deux% EQU 0 ( ECHO Division by zero, please try again! GOTO START ) ELSE ( SET /A div=%un%/%deux% ) ECHO. ECHO %un% / %deux% = %div% ECHO. GOTO SUITE :SUBTRACTION SET /A sub=%un%-%deux% ECHO. ECHO %un% - %deux% = %sub% ECHO. GOTO SUITE :ADDITION SET /A add=%un%+%deux% ECHO. ECHO %un% + %deux% = %add% ECHO. GOTO SUITE :END cls EOF 



0
brucine Posted messages 24494 Registration date   Status Membre Last intervention   4 114 > brucine Posted messages 24494 Registration date   Status Membre Last intervention  
 

It seems there was a new fleeting contribution that leads me to a clarification: when you love, you don't count; it's true in this case.

Besides the four basic operations, for which one cannot develop a pure batch calculator, Professor Salmi, who was one of the few batch gurus in the 2000s, proposed several alternatives for more or less sophisticated scientific calculators, but all of them didn't rely on pure batch but on a third-party utility.

See here, tscmd.zip, item 61:

http://ftp.lip6.fr/pub/pc/garbo/pc/link/

0
little boy62 Posted messages 4393 Registration date   Status Membre Last intervention   1 790 > brucine Posted messages 24494 Registration date   Status Membre Last intervention  
 

Hello

Mine, in this case.

Actually, I made a rookie mistake: I thought the aid requester had created this batch.

But they hadn’t. I should have paid attention.

So, my message was unnecessary.

I self-moderated ^^

++

0