:Calcu
color 4D
mode 250
echo -----------------------------------------------------------------------------------------------
echo Welcome To The Calculator
echo -----------------------------------------------------------------------------------------------
echo "------>You have the option do Adding Subtraction Multiplication and Division just type<-------"
echo "------>the question and it will give you the answer for each of the type<-------"
echo -----------------------------------------------------------------------------------------------
echo Type 1 For Addition, 2 For Subtraction, 3 For Multiplication And 4 For Division:
@set /p Type=
IF /I %Type%==1 (
echo Addition
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Sum = %First% + %Second%
echo %First% + %Second% = %Sum%
)
IF /I %Type%==2 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Sub = %First% - %Second%
echo %First% - %Second% = %Sub%
)
IF /I %Type%==3 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Multi = %First% * %Second%
echo %First% X %Second% = %Multi%
)
IF /I %Type%==4 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Div = %First% / %Second%
echo %First% ÷ %Second% = %Div%
)
IF /I %Type%=>5 (
echo Not a Valid Number
)
pause
goto Calcu
谁能告诉我为什么我缺少操作数错误
我正在尝试使此计算器正常工作,但无法正常工作
数学运算在另一个代码块中有效,但在这里不起作用
最佳答案
设置变量时,请勿在=
周围使用空格,否则空格将成为变量名称或值的一部分。
set /p First = Enter First Number:
echo %first%
echo %first %
set /p "First=Enter First Number: "
echo %first%
至于delayed Expansion,JosefZ提到:
if A==A (
set /p First = Enter First Number:
echo %first% - !first!
echo %first % - !first !
set /p "First=Enter First Number: "
echo %first% - !first!
)
关于math - 在CMD中所有方程式都缺少操作数错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32660947/