Epic_Tonic
Epic_Tonic

Reputation: 96

If number is at certain range, do (command here)

I would like to ask you a question.

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

Any ideas?

Upvotes: 2

Views: 6827

Answers (2)

LS_ᴅᴇᴠ
LS_ᴅᴇᴠ

Reputation: 11181

One number between minand max is just number>=max AND number<=min, right???

IF %BDF1% GEQ 80 IF %BFD1% LEQ 90 GOTO :HAPPY

Upvotes: 4

Endoro
Endoro

Reputation: 37589

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 :)

Upvotes: 2

Related Questions