如果数字在一定范围内,请执行(在此处命令) [英] If number is at certain range, do (command here)

查看:90
本文介绍了如果数字在一定范围内,请执行(在此处命令)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问你一个问题.

我正在创建一个简单的程序来扫描数字(人的成绩),并检查它们是否在某个范围内(例如75%到90%),如果它们在某个范围内,请执行以下命令;这是代码.

I am creating a simple program that scans numbers (people's grades) and checks if they are at a certain range (say, 75% to 90%) and if they are at a certain range, do the following command; here's the code.

(代码下方的更多文本)

(More text below the code)

@echo off
color a
title Happy Factor Decoder
echo Hello!
set /p eg="Exam Grade (RAW): "
set /p teg="TOTAL RAW Exam Grade (The highest score): "
echo Calculating
set /a m=%teg% - %eg%
echo You had %m% mistakes
echo Breaking down...
timeout /t 1 >nul
set /a bdf1=%eg% / 4
echo %bdf1%
set /a bdf2=%teg% / 4
echo %bdf2%
set /a bdf3=%m% / 4
echo %bdf3%
echo I BROKE IT DOWN YEAH :D
if %eg% == 4 goto happy
if %eg% == 3 goto kindahappy
if %eg% == 2 goto kindasad
if %eg% == 1 goto sad

:happy
echo Your father will be happy about this
pause

:kindahappy
echo Your father will be KINDA happy about this
pause

:kindasad
echo Your father will be KINDA sad about this
pause

:sad
echo Your father will be sad about this
pause

您知道,我想要它做的就是这个(用伪代码)

You see, What i want it to do is this (in pseudocode)

IF BDF1 IS AT CERTAIN RANGE (80-90) GOTO HAPPY

有什么想法吗?

推荐答案

我不知道您的计算单位,但是您可以检查从最低到最高的范围:

I don't know the units of your calculations, but you can check a range from lowest to high:

@ECHO OFF &SETLOCAL
REM some calculation here
IF %BDF1% leq 25 GOTO :sad
IF %BDF1% leq 50 GOTO :kindasad
IF %BDF1% leq 75 GOTO :kindahappy
IF %BDF1% leq 100 GOTO :happy
ECHO uups!
goto:eof

:sad
ECHO sad
goto:eof

:kindasad
ECHO kindased
goto:eof

:kindahappy
ECHO kindahappy
goto:eof

:happy
REM please enter your code here :)

这篇关于如果数字在一定范围内,请执行(在此处命令)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆