我编写了这个程序来将分数转换为百分比,但我的 goto 命令被跳过了。它通过程序并跳过 if 语句。这是代码:
@echo off
:menu
Echo Fraction to Percent=1
Echo Percent to Fraction =2
set /p choice =Enter the number of your choice:
if choice == 1 goto ftp
if choice == 2 goto ptf
if choice == 3 Exit
:ptf
pause
:ftp
set /p tn= Enter the top number:
set /p bn= Enter the Bottom number:
set /a mtn= %tn% * 100
set /a cf= %mtn% / %bn%
set /a cf2= %cf% * 10000
set /a mtn3= %tn% * 1000000
set /a cf3= %mtn3% / %bn%
set /a cf4= %cf3% - %cf2%
set /a cf5= %cf2% / 10000
echo %cf5%.%cf4%
goto continue
:continue
set /p con =Continue? (y/n):
if con ==y goto ftp
if con ==n goto menu