I am trying to get a batch file to test if a number is between two numbers but it is only checking for the first number. I am using the "and" operator but it doesn't seem to be working. Here's the code:
REM Used to keep variable for duration of script
setlocal enabledelayedexpansion
cls
@echo off
echo Math Experts Commands
set /p loop=Loop how many times:
for /L %%A IN (1,1,!loop!) DO (
REM Request the first number
echo Enter your first digit you wish to add
REM Set first user input to "num1"
set /p num1=
REM Request the second number
echo Enter the second digit you wish to add the first by
REM Set second usr input to "num2"
set /p num2=
REM Add the 2 values then set the outcome to "total"
set /a total=num1+num2
REM Clear the screen
cls
if !total! leq 4 (
echo ####################################################################################
echo # Hosts Req: # Mask: # Netmask: # Max Supported: #
echo # !total! /30 255.255.255.252 4 #
echo ####################################################################################
echo.
) else if !total! gtr 4 and leq 8 ( REM <----WHERE THE PROBLEM IS.
echo ####################################################################################
echo # Hosts Req: # Mask: # Netmask: # Max Supported: #
echo # !total! /29 255.255.255.248 8 #
echo ####################################################################################
echo.
)
)
REM Pause the console
pause
echo.
)