How do I use basic batch math commands to come up with decimal answers?

前端 未结 4 655
名媛妹妹
名媛妹妹 2021-01-15 22:10

I am making a batch file so that I just tell it what kind of formula I need to use and it tells me what variables I need to input. Right now, I am coding it so that it will

4条回答
  •  别那么骄傲
    2021-01-15 22:38

    You can try it like that with a batch file :

    @echo off
    set /p "TriangleB=How long is the base of the triangle ? (Don't put the unit, just put the number): "
    set /p "TriangleH=What is the height of the triangle ? (Don't put the unit, just put the number): "
    set /p "TriangleAreaUnit=What unit is the triangle being measured in ?: "
    Call :makevbs %TriangleB% %TriangleH%
    echo The area of the triangle is %TriangleArea% %TriangleAreaUnit%^2.
    pause >nul
    Exit /b
    
    :makevbs
    echo wscript.echo Eval( wscript.Arguments(0^) * wscript.Arguments(1^) / 2^) > "%tmp%\%~n0.vbs"
    for /f %%A in ('cscript /nologo "%tmp%\%~n0.vbs" %~1 %~2') do set TriangleArea=%%A
    exit /b
    

提交回复
热议问题