@REM Time function is not working properly (yet) ::Example:: ::If there is a straight section of highway 120 Km between them and Joe travels south towards ::Bob at 30Kph while Bob travels north towards Joe at 25Kph how long will it be before they ::meet and how far will each have traveled in that time? ::https://www.facebook.com/groups/ILMFP/ ::Joe: ::Starting distance: 0 ::Starting time: 0 ::Speed: 30 ::Bob: ::Starting Distance: 120 ::Starting time: 0 ::Speed: -25 (negative because Bob is going to Joe) ::Output: ::Meeting time: 2,181 h ::Distance Joe: 65.430 km ::Distance Bob: 54.525 km @REM I <3 Math for programming! @REM (c) Robin "yugecin" Claerhout @echo off :a call:table "1" set /p a=ÈÍ^> if not defined a goto a :b call:table "2" set /p b=ÈÍ^> if not defined b goto b :c call:table "3" set /p c=ÈÍ^> if not defined c goto c :d call:table "4" set /p d=ÈÍ^> if not defined d goto d :e call:table "5" set /p e=ÈÍ^> if not defined e goto e :f call:table "6" set /p f=ÈÍ^> if not defined f goto f cls if %c% LSS %f% ( if %a% LSS %d% ( echo They will never meet! pause goto a ) ) ::%a% sdistance joe ::%b% stime joe ::%c% speed joe ::%d% sdistance bob ::%e% stime bob ::%f% speed bob ::ERB joe = sdistance + speed*t - speed*stime :: = %a% + %c%*t - %c%*%b% ::ERB bob = sdistance + speed*t - speed*stime :: = %d% + %f%*t - %f%*%e% :: %a% + %c%*t - %c%*%b% = %d% + %f%*t - %f%*%e% :: (%c%-%f%)*t = %d% - %a% - %f%*%e% + %c%*%b% :: t = (%d% - %a% - %f%*%e% + %c%*%b%)/(%c%-%f%) set /a a*=1000 set /a b*=1000 set /a c*=1000 set /a d*=1000 set /a e*=1000 set /a f*=1000 set /a t=(%d% - %a% - %f%*%e% + %c%*%b%)/(%c%/1000-%f%/1000) if %t% GTR 999 ( echo Meeting time: %t:~0,1%,%t:~1,3% h ) else ( if %t% GTR 99 ( echo Meeting time: 0.%t% h ) else ( echo Meeting time: 0.0%t% h ) ) ::if %c% LSS 0 set /a c*=-1 ::if %f% LSS 0 set /a f*=-1 set /a i=%c%*%t% set /a j=%f%*%t% set /a i/=1000 set /a j/=1000 if %i% LSS 0 set /a i*=-1 if %j% LSS 0 set /a j*=-1 rem set /a i=%a%-%i% rem set /a j=%d%-%j% rem if %i% LSS 0 set /a i*=-1 rem if %j% LSS 0 set /a j*=-1 if %i% GTR 99999 ( echo Distance Joe: %i:~0,3%.%i:~3,7% km ) else ( if %i% GTR 9999 ( echo Distance Joe: %i:~0,2%.%i:~2,5% km ) else ( if %i% GTR 999 ( echo Distance Joe: %i:~0,1%.%i:~1,3% km ) else ( if %i% GTR 99 ( echo Distance Joe: 0.%i% km ) else ( echo Distance Joe: 0.0%i% km ) ) ) ) if %j% GTR 99999 ( echo Distance Bob: %j:~0,3%.%j:~3,3% km ) else ( if %j% GTR 9999 ( echo Distance Bob: %j:~0,2%.%j:~2,3% km ) else ( if %j% GTR 999 ( echo Distance Bob: %j:~0,1%.%j:~1,3% km ) else ( if %j% GTR 99 ( echo Distance Bob: 0.%j% km ) else ( echo Distance Bob: 0.0%j% km ) ) ) ) pause goto a exit /b :table setlocal cls echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» echo º Joe º Bob º echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ set "a= Starting distance (km)" if "%~1" EQU "1" set "a=^>Starting distance (km)" set "b= Starting distance (km)" if "%~1" EQU "4" set "b=^>Starting distance (km)" echo º %a% º %b% º set "a= Starting time (h)" if "%~1" EQU "2" set "a=^>Starting time (h)" set "b= Starting time (h)" if "%~1" EQU "5" set "b=^>Starting time (h)" echo º %a% º %b% º set "a= Speed (km/h)" if "%~1" EQU "3" set "a=^>Speed (km/h)" set "b= Speed (km/h)" if "%~1" EQU "6" set "b=^>Speed (km/h)" echo º %a% º %b% º echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ endlocal GOTO:EOF